-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
106 lines (95 loc) · 2.85 KB
/
index.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const TelegramBot = require("node-telegram-bot-api");
// replace the value below with the Telegram token you receive from @BotFather
const token = "https://app.clickup.com/613523/v/dc/jq4k-1524";
// Create a bot that uses 'polling' to fetch new updates
const bot = new TelegramBot(token, { polling: true });
// Matches "/echo [whatever]"
bot.onText(/\/echo (.+)/, (msg, match) => {
// 'msg' is the received Message from Telegram
// 'match' is the result of executing the regexp above on the text content
// of the message
const chatId = msg.chat.id;
const resp = match[1]; // the captured "whatever"
// send back the matched "whatever" to the chat
bot.sendMessage(chatId, "sssssss");
});
bot.onText(/\/newcommand/, (msg, match) => {
// 'msg' is the received Message from Telegram
// 'match' is the result of executing the regexp above on the text content
// of the message
const opts = {
reply_to_message_id: msg.message_id,
reply_markup: {
resize_keyboard: true,
one_time_keyboard: true,
inline_keyboard: [
[
{
text: "Development",
callback_data: "development",
},
{
text: "Lifestyle",
callback_data: "lifestyle",
},
{
text: "Other",
callback_data: "other",
},
],
],
},
};
// const chatId = msg.chat.id;
// const resp = match[1]; // the captured "whatever"
// // send back the matched "whatever" to the chat
// bot.sendMessage(chatId, "sssssss");
});
const requestPhoneKeyboard = {
reply_markup: {
one_time_keyboard: true,
inline_keyboard: [
[
[
{
text: "Development",
callback_data: "development",
},
{
text: "Lifestyle",
callback_data: "lifestyle",
},
{
text: "Other",
callback_data: "other",
},
],
],
],
},
};
// Listener (handler) for retrieving phone number
bot.onText(/\/phone/, (msg) => {
bot.sendMessage(
msg.chat.id,
"Can we get access to your phone number?",
requestPhoneKeyboard
);
// bot.sendMessage(msg.chat.id, "I'm a test robot", opts);
});
bot.onText(/\/bogo (.+)/, (msg, match) => {
// 'msg' is the received Message from Telegram
// 'match' is the result of executing the regexp above on the text content
// of the message
const chatId = msg.chat.id;
const resp = match[1]; // the captured "whatever"
// send back the matched "whatever" to the chat
bot.sendMessage(chatId, "sssssss");
});
// Listen for any kind of message. There are different kinds of
// messages.
bot.on("message", (msg) => {
const chatId = msg.chat.id;
// send a message to the chat acknowledging receipt of their message
bot.sendMessage(chatId, "Received your message hehehe");
});