forked from mullwar/telebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule-cmdbutton.js
40 lines (31 loc) · 932 Bytes
/
module-cmdbutton.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
'use strict';
const TeleBot = require('../');
const bot = new TeleBot('-PASTEYOURTELEGRAMBOTAPITOKENHERE-');
// Use command button module
bot.use(require('../modules/cmdbutton.js'));
// Command /start
bot.on('/start', msg => {
// Inline keyboard markup
let markup = bot.inlineKeyboard([
[
// Button in first row with command callback
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.', { markup });
});
// Command /hello
bot.on('/hello', msg => {
return bot.sendMessage(msg.from.id, 'Hello!');
});
// Button callback
bot.on('callbackQuery', msg => {
console.log(`[callback] ${ msg.data }`);
bot.answerCallback(msg.id);
});
bot.connect();