Update server.js
This commit is contained in:
parent
0868bbfc95
commit
c945de23df
1 changed files with 0 additions and 19 deletions
19
server.js
19
server.js
|
@ -1,20 +1 @@
|
|||
var TelegramBot = require('node-telegram-bot-api');
|
||||
|
||||
var token = 'YOUR_TELEGRAM_BOT_TOKEN';
|
||||
// Setup polling way
|
||||
var bot = new TelegramBot(token, {polling: true});
|
||||
|
||||
// Matches /echo [whatever]
|
||||
bot.onText(/\/echo (.+)/, function (msg, match) {
|
||||
var fromId = msg.from.id;
|
||||
var resp = match[1];
|
||||
bot.sendMessage(fromId, resp);
|
||||
});
|
||||
|
||||
// Any kind of message
|
||||
bot.on('message', function (msg) {
|
||||
var chatId = msg.chat.id;
|
||||
// photo can be: a file path, a stream or a Telegram file_id
|
||||
var photo = 'cats.png';
|
||||
bot.sendPhoto(chatId, photo, {caption: 'Lovely kittens'});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue