forked from mullwar/telebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin-commandButton.js
41 lines (31 loc) · 945 Bytes
/
plugin-commandButton.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
const TeleBot = require('../');
const bot = new TeleBot({
token: 'TELEGRAM_BOT_TOKEN',
usePlugins: ['commandButton']
});
// Command /start
bot.on('/start', msg => {
// Inline keyboard markup
const replyMarkup = bot.inlineKeyboard([
[
// First row with command callback button
bot.inlineButton('Command button', {callback: '/hello'})
],
[
// Second row with regular command button
bot.inlineButton('Regular data button', {callback: 'hello'})
]
]);
// Send message with keyboard markup
return bot.sendMessage(msg.from.id, 'Example of command button.', {replyMarkup});
});
// Command /hello
bot.on('/hello', msg => {
return bot.sendMessage(msg.from.id, 'Hello!');
});
// Button callback
bot.on('callbackQuery', (msg) => {
console.log('callbackQuery data:', msg.data);
bot.answerCallbackQuery(msg.id);
});
bot.start();