forked from mullwar/telebot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathask.js
More file actions
39 lines (26 loc) · 687 Bytes
/
ask.js
File metadata and controls
39 lines (26 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
Name: Ask
Description: Get direct answers from users!
*/
// Store user list
const userList = {};
module.exports = bot => {
// On every text message
bot.on('*', (msg, info) => {
let id = msg.chat.id,
ask = userList[id];
// If no question, then it's a regular message
if (!ask) return;
// Delete user from list and send custom event
delete userList[id];
bot.event('ask.' + ask, msg, info);
});
// Before call sendMessage method
bot.on('sendMessage', args => {
let id = args[0],
opt = args[2] || {};
let ask = opt.ask;
// If "ask" in options, add user to list
if (ask) userList[id] = ask;
});
};