forked from mullwar/telebot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnamedButtons.js
More file actions
34 lines (26 loc) · 716 Bytes
/
namedButtons.js
File metadata and controls
34 lines (26 loc) · 716 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
/*
Named buttons which triggers bot commands.
*/
module.exports = {
id: 'namedButtons',
defaultConfig: {
buttons: {
// myButton: {
// label: '😄 My Button Name',
// command: '/myBotCommand'
// }
}
},
plugin(bot, pluginConfig) {
const buttons = pluginConfig.buttons || {};
bot.on('text', (msg, props) => {
const text = msg.text;
for (let buttonId in buttons) {
const button = buttons[buttonId];
if (button.label === text) {
return bot.event(button.command, msg, props);
}
}
});
}
};