-
Notifications
You must be signed in to change notification settings - Fork 2
/
bot.js
61 lines (42 loc) · 1.45 KB
/
bot.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
50
51
52
53
54
55
56
57
58
59
60
61
const TelegramBot = require('node-telegram-bot-api');
const token = process.env.TOKEN
const bot = new TelegramBot(token , {polling: true})
const request = require('request')
bot.on("polling_error", console.log);
bot.onText(RegExp("\/meme") , (msg) => {
var opts = {
inline_keyboard : [
[
{
text:"Next",
callback_data: "next"
}
]
]
}
var kek = request("https://nksamamemeapi.pythonanywhere.com" , {json: true} , (err , res , body) => {
bot.sendPhoto(msg.chat.id , body.image , {caption: body.title , reply_markup: opts})
})
})
bot.onText(RegExp("\/start"), (msg) => {
bot.sendMessage(msg.chat.id , "<i> Hello , use /meme to get a new meme </i>", {parse_mode: "HTML"})
})
bot.on("callback_query" , (callbackQuery) => {
const msg = callbackQuery.message
var opts = {
inline_keyboard : [
[
{
text:"Next",
callback_data: "next"
}
]
]
}
if (callbackQuery.data === "next") {
bot.deleteMessage(msg.chat.id , callbackQuery.message.message_id);
request("https://nksamamemeapi.pythonanywhere.com" , {json: true} , (err , res , body) => {
bot.sendPhoto(msg.chat.id , body.image , {caption: body.title , reply_markup: opts})
});
}
})