-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
55 lines (40 loc) · 1.55 KB
/
index.js
File metadata and controls
55 lines (40 loc) · 1.55 KB
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
50
51
52
53
54
55
// libs
const request = require('request'),
telegramBot = require('node-telegram-bot-api');
require('dotenv').config();
// creating bot
const bot = new telegramBot(process.env.TOKEN, {polling: true});
// remove keyboard
const optRemove = {
reply_markup: {
remove_keyboard: true
}
};
bot.on('message', (msg) => {
var oi = "oi";
if (msg.text.toString().toLowerCase().indexOf(oi) === 0) {
bot.sendMessage(msg.chat.id,"Oi bb");
}
var robot = "I'm robot";
if (msg.text.indexOf(robot) === 0) {
bot.sendMessage(msg.chat.id, "Yes I'm robot but not in that way!", optRemove);
}
});
bot.onText(/bb/, (msg) => {
bot.sendMessage(msg.chat.id,"tá me chamando de bebê?");
})
// commands
bot.onText(/^\/start(@\w+)*$/, (msg) => {
var url = `https://trello.com/1/authorize?expiration=1day&name=HappyTaskReminderBot&scope=read&response_type=token&key=${process.env.TRELLOKEY}`
bot.sendMessage(msg.chat.id, "Welcome " + url);
});
bot.onText(/^\/healthcheck(@\w+)*$/, (msg) => {
bot.sendMessage(msg.chat.id, "I'm alive!");
});
bot.onText(/^\/happyface(@\w+)*$/, (msg) => {
bot.sendPhoto(msg.chat.id,"https://cdn.expansion.mx/dims4/default/7dfd775/2147483647/thumbnail/800x450%5E/quality/75/?url=https%3A%2F%2Fcdn.expansion.mx%2Fphotos%2F2007%2F07%2F01%2Fla-nueva-campana-mostrara-a-actores-hablando-sobre-por-que-vuelven-a-wal-mart-en-busca-de-precios-mas-bajos-y-no-la-carita-feliz-reuters.2007-07-23.6291503003.jpg" );
});
// handling errors
bot.on('polling_error', (error) => {
console.log(error.code); // => 'EFATAL'
});