forked from mullwar/telebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin-namedButtons.js
44 lines (35 loc) · 972 Bytes
/
plugin-namedButtons.js
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
40
41
42
43
44
const TeleBot = require('../');
const BUTTONS = {
hello: {
label: '👋 Hello',
command: '/hello'
},
world: {
label: '🌍 World',
command: '/world'
},
hide: {
label: '⌨️ Hide keyboard',
command: '/hide'
}
};
const bot = new TeleBot({
token: 'TELEGRAM_BOT_TOKEN',
usePlugins: ['namedButtons'],
pluginConfig: {
namedButtons: {
buttons: BUTTONS
}
}
});
bot.on('/hello', (msg) => msg.reply.text('Hello command!'));
bot.on('/world', (msg) => msg.reply.text('World command!'));
bot.on('/hide', (msg) => msg.reply.text('Type /start to show keyboard again.', {replyMarkup: 'hide'}));
bot.on('/start', (msg) => {
let replyMarkup = bot.keyboard([
[BUTTONS.hello.label, BUTTONS.world.label],
[BUTTONS.hide.label]
], {resize: true});
return bot.sendMessage(msg.from.id, 'See keyboard below.', {replyMarkup});
});
bot.start();