From 77da29859190650e7a5709472dd02625032df8e0 Mon Sep 17 00:00:00 2001 From: JianMiau Date: Fri, 25 Apr 2025 10:30:26 +0800 Subject: [PATCH] =?UTF-8?q?[add]=20help=20=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/app.js b/app.js index bf52221..04c886c 100644 --- a/app.js +++ b/app.js @@ -24,8 +24,26 @@ bot.onText(/\/start/, function (msg) { bot.onText(/\/help/, function (msg) { const chatId = msg.chat.id; - const resp = '才不告訴逆雷'; - bot.sendMessage(chatId, resp); + const helpText = ` + 🤖 Bot 指令清單: + + /help - 顯示這份幫助說明 + + /roll [XdY] - 擲骰指令,代表x顆y面骰,範例:/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 list = match[1].split(',').map(item => item.trim()).filter(Boolean); - - if (list.length === 0) { + if (!match[1]) { return bot.sendMessage(chatId, '⚠️ 請提供正確的選項格式,例如:/draw [香蕉, 你個, 芭樂]'); } - const pick = list[Math.floor(Math.random() * list.length)]; - bot.sendMessage(chatId, `🎯 從 [${list.join(', ')}] 中抽出:\n👉 ${pick}`); + const options = match[1].split(',').map(o => o.trim()).filter(o => o.length > 0); + + 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) => {