-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbot.js
More file actions
100 lines (86 loc) · 2.63 KB
/
Copy pathbot.js
File metadata and controls
100 lines (86 loc) · 2.63 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
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
const TelegramBot = require('node-telegram-bot-api');
const api = require('./api');
const ONBOARDING_URL = 'https://nex-ton.github.io/Nexton_Onboarding_Frontend/';
const NEXTON_URL = 'https://www.nexton.tg';
const GLOBAL_CHANNEL_URL = 'https://t.me/nextonglobal';
const LANDING_PAGE_URL = 'https://www.nexton.solutions/';
const ARBITRAGE_BOT_PERFORMANCE_URL = 'https://t.me/+_qrUElvbPRtlZDI1';
const COMMUNITY_URL='https://t.me/NextonOfficialCommunity';
const CS_CHANNEL_URL = 'https://t.me/m/-Y3bstHbMzE9';
const IMG_URL =
`https://nextonserver.s3.eu-north-1.amazonaws.com/NextonBannerV2.png`;
// 'https://nextonserver.s3.eu-north-1.amazonaws.com/nexton_stake.jpg';
// Initialize the bot
const token = process.env.TELEGRAM_BOT_TOKEN;
const bot = new TelegramBot(token, { polling: true });
async function logUserInteraction(userId, action, parameter) {
try {
await api.post('data/analytics/log', {
userId,
action,
parameter,
});
} catch (error) {
console.error('Error logging user interaction:', error);
}
}
bot.onText(/\/start (.+)/, (msg, match) => {
const chatId = msg.chat.id;
const param = match[1];
logUserInteraction(chatId, 'started', param);
});
bot.onText(/\/start$/, msg => {
const chatId = msg.chat.id;
logUserInteraction(chatId, 'started', 'no_param');
sendWelcomeMessage(chatId);
});
bot.onText(/\/stake (\d+) (\d+)/, (msg, match) => {
const chatId = msg.chat.id;
const var1 = match[1];
const var2 = match[2];
bot.sendMessage(chatId, `You staked ${var1} and ${var2}.`);
});
function sendWelcomeMessage(chatId) {
const message =
'Stake $TON, receive a Nexton NFT, and benefit from staking and arbitrage yields!';
const button1 = {
text: '🚀 Open Nexton',
web_app: { url: NEXTON_URL },
};
const button2 = {
text: '👥 Join our Global Channel',
url: GLOBAL_CHANNEL_URL,
};
const button3 = {
text: '🔥 Join Our Official Community',
url: COMMUNITY_URL,
};
const button4 = {
text: '👋 Official Website',
url: LANDING_PAGE_URL,
};
const button5 = {
text: '📊 Go to Arbitrage Bot Performance',
url: ARBITRAGE_BOT_PERFORMANCE_URL,
};
const button6 = {
text: '👉 Go to the CS channel',
url: CS_CHANNEL_URL,
};
const inlineButtons = [[button1], [button2], [button3], [button4], [button5], [button6]];
const buttonOptions = {
reply_markup: {
inline_keyboard: inlineButtons,
},
};
bot
.sendPhoto(chatId, IMG_URL, {
parse_mode: 'HTML',
caption: message,
...buttonOptions,
})
.catch(error => {
console.error('Error sending photo:', error);
});
}
module.exports = { bot };