[add] /draw 抽籤系統
This commit is contained in:
parent
964389cf1a
commit
cecfd69bc5
19
app.js
19
app.js
@ -28,7 +28,9 @@ bot.onText(/\/help/, function (msg) {
|
|||||||
bot.sendMessage(chatId, resp);
|
bot.sendMessage(chatId, resp);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 收到roll開頭的訊息時會觸發這段程式
|
/**
|
||||||
|
* 骰子系統
|
||||||
|
*/
|
||||||
bot.onText(/\/roll(?:@[\w_]+)?(?:\s+(\d*)d(\d+))?/i, function (msg, match) {
|
bot.onText(/\/roll(?:@[\w_]+)?(?:\s+(\d*)d(\d+))?/i, function (msg, match) {
|
||||||
// console.log(`✅ Bot roll`);
|
// console.log(`✅ Bot roll`);
|
||||||
|
|
||||||
@ -47,6 +49,21 @@ bot.onText(/\/roll(?:@[\w_]+)?(?:\s+(\d*)d(\d+))?/i, function (msg, match) {
|
|||||||
bot.sendMessage(chatId, resp);
|
bot.sendMessage(chatId, resp);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抽籤系統
|
||||||
|
*/
|
||||||
|
bot.onText(/\/draw(?:@[\w_]+)?\s+\[([^\]]+)\]/i, (msg, match) => {
|
||||||
|
const chatId = msg.chat.id;
|
||||||
|
const list = match[1].split(',').map(item => item.trim()).filter(Boolean);
|
||||||
|
|
||||||
|
if (list.length === 0) {
|
||||||
|
return bot.sendMessage(chatId, '⚠️ 請提供正確的選項格式,例如:/draw [香蕉, 你個, 芭樂]');
|
||||||
|
}
|
||||||
|
|
||||||
|
const pick = list[Math.floor(Math.random() * list.length)];
|
||||||
|
bot.sendMessage(chatId, `🎯 從 [${list.join(', ')}] 中抽出:\n👉 ${pick}`);
|
||||||
|
});
|
||||||
|
|
||||||
bot.onText(/\/everyone/, async (msg) => {
|
bot.onText(/\/everyone/, async (msg) => {
|
||||||
if (msg.chat.type !== 'group' && msg.chat.type !== 'supergroup') {
|
if (msg.chat.type !== 'group' && msg.chat.type !== 'supergroup') {
|
||||||
return bot.sendMessage(msg.chat.id, '⚠️ 此指令僅限群組使用');
|
return bot.sendMessage(msg.chat.id, '⚠️ 此指令僅限群組使用');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user