MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / lottery

Function lottery

lottery/lottery.ts:1043–1742  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

1041• 管理员可使用 <code>${mainPrefix}lottery draw</code> 提前手动开奖`;
1042
1043const lottery = async (msg: Api.Message) => {
1044 const client = await getGlobalClient();
1045 if (!client) {
1046 await msg.edit({ text: "❌ 客户端未初始化", parseMode: "html" });
1047 return;
1048 }
1049
1050 try {
1051 // 严格按照acron.ts模式进行参数解析
1052 const lines = msg.text?.trim()?.split(/\r?\n/g) || [];
1053 const parts = lines?.[0]?.split(/\s+/) || [];
1054 const [, ...args] = parts; // 跳过命令本身
1055 const sub = (args[0] || "").toLowerCase();
1056
1057 // Get chat ID
1058 let chatId: string;
1059 try {
1060 if (msg.chat?.id) {
1061 chatId = String(msg.chat.id);
1062 } else if (msg.peerId) {
1063 chatId = String(msg.peerId);
1064 } else if (msg.chatId) {
1065 chatId = String(msg.chatId);
1066 } else {
1067 throw new Error("无法获取聊天ID");
1068 }
1069 } catch (error) {
1070 await msg.edit({
1071 text: `❌ <b>获取聊天ID失败:</b> ${htmlEscape(String(error))}`,
1072 parseMode: "html"
1073 });
1074 return;
1075 }
1076
1077 // 无参数时显示错误提示,不自动显示帮助
1078 if (!sub) {
1079 await msg.edit({
1080 parseMode: "html"
1081 });
1082 return;
1083 }
1084
1085 // 明确请求帮助时才显示
1086 if (sub === "help" || sub === "h") {
1087 await msg.edit({
1088 text: help_text,
1089 parseMode: "html",
1090 linkPreview: false,
1091 });
1092 return;
1093 }
1094
1095 if (sub === "init" || sub === "initialize") {
1096 await msg.edit({
1097 text: "🔄 <b>正在初始化数据库...</b>",
1098 parseMode: "html"
1099 });
1100

Callers

nothing calls this directly

Calls 15

getPrizeWarehousesFunction · 0.85
getWarehousePrizesFunction · 0.85
getActiveLotteryFunction · 0.85
createLotteryConfigFunction · 0.85
isUserAdminFunction · 0.85
performLotteryDrawFunction · 0.85
deleteLotteryActivityFunction · 0.85
getLotteryParticipantsFunction · 0.85
createPrizeWarehouseFunction · 0.85
addPrizeToWarehouseFunction · 0.85

Tested by

no test coverage detected