[add] help 完善

This commit is contained in:
建喵 2025-04-25 10:30:26 +08:00
parent cecfd69bc5
commit 77da298591

38
app.js
View File

@ -24,8 +24,26 @@ bot.onText(/\/start/, function (msg) {
bot.onText(/\/help/, function (msg) { bot.onText(/\/help/, function (msg) {
const chatId = msg.chat.id; const chatId = msg.chat.id;
const resp = '才不告訴逆雷'; const helpText = `
bot.sendMessage(chatId, resp); 🤖 Bot 指令清單
/help -
/roll [XdY] - xy/roll 2d6
/draw [1, 2, 3] -
/everyone - username 使使
🎲 小提醒/roll 的最大支援為 100 顆骰最大面數為 1000
📌 你的發話紀錄會自動儲存以便 /everyone 使用
🛠 更多功能開發中...
`;
if (msg.from.id === 6218259358) {
const resp = '才不告訴逆雷';
bot.sendMessage(chatId, resp);
} else {
bot.sendMessage(chatId, helpText);
}
}); });
/** /**
@ -52,16 +70,20 @@ bot.onText(/\/roll(?:@[\w_]+)?(?:\s+(\d*)d(\d+))?/i, function (msg, match) {
/** /**
* 抽籤系統 * 抽籤系統
*/ */
bot.onText(/\/draw(?:@[\w_]+)?\s+\[([^\]]+)\]/i, (msg, match) => { bot.onText(/\/draw(?:@[\w_]+)?\s*\[(.+)\]/i, function (msg, match) {
const chatId = msg.chat.id; const chatId = msg.chat.id;
const list = match[1].split(',').map(item => item.trim()).filter(Boolean); if (!match[1]) {
if (list.length === 0) {
return bot.sendMessage(chatId, '⚠️ 請提供正確的選項格式,例如:/draw [香蕉, 你個, 芭樂]'); return bot.sendMessage(chatId, '⚠️ 請提供正確的選項格式,例如:/draw [香蕉, 你個, 芭樂]');
} }
const pick = list[Math.floor(Math.random() * list.length)]; const options = match[1].split(',').map(o => o.trim()).filter(o => o.length > 0);
bot.sendMessage(chatId, `🎯 從 [${list.join(', ')}] 中抽出:\n👉 ${pick}`);
if (options.length === 0) {
return bot.sendMessage(chatId, '⚠️ 沒有有效的選項');
}
const choice = options[Math.floor(Math.random() * options.length)];
bot.sendMessage(chatId, `🎯 從 [${options.join(', ')}] 中抽出:\n👉 ${choice}`);
}); });
bot.onText(/\/everyone/, async (msg) => { bot.onText(/\/everyone/, async (msg) => {