-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpollubot.js
49 lines (42 loc) · 1.22 KB
/
pollubot.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
45
46
47
48
49
var TelegramBot = require('node-telegram-bot-api');
var token = '',
USER = 114222213,
// Setup polling way
bot = new TelegramBot(token, {polling: true}),
opts = {
reply_markup: JSON.stringify(
{
force_reply: true
}
)};
/*
bot.sendMessage(USER, 'How old are you?', opts).then(function (sended) {
var chatId = sended.chat.id;
var messageId = sended.message_id;
bot.onReplyToMessage(chatId, messageId, function (message) {
console.log('User is %s years old', message.text);
});
});
*/
// Matches /echo [whatever]
bot.onText(/\/pm10/, function (msg, match) {
console.log(msg);
var fromId = msg.from.id;
console.log(fromId);
var resp = match[1];
bot.sendMessage(fromId, resp);
});
bot.onText(/\/start/, function (msg, match) {
var name = msg.from.first_name || msg.from.username,
fromId = msg.from.id;
var welcome = "*Benvenuto " + name + "*";
welcome += "\n``` PolluBot ti fornisce tutte le informazioni riguardo l'inquinamento nella tua zona ";
welcome += "\no nella località preferita.```";
bot.sendMessage(fromId, welcome, {'parse_mode': 'Markdown'});
});
/*
bot.on('message', function (msg) {
var chatId = msg.chat.id;
bot.sendMessage(chatId, '*Prova invio*', {'parse_mode': 'Markdown'});
});
*/