-
Notifications
You must be signed in to change notification settings - Fork 3
/
send_announcement.js
68 lines (54 loc) · 1.91 KB
/
send_announcement.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
require('dotenv').config();
const TelegramBot = require('node-telegram-bot-api');
const _ = require('underscore');
const user = require('./models').user;
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
(async function () {
const bot = new TelegramBot(process.env.TELEGRAM_TOKEN, {
polling: false,
});
let resp = '*@webdollar_tip_bot bot has been updated:*\n\n';
resp += ' \t ✅ Added a 24 hour wait period for withdraws. \n\n';
resp +=
' \t ✅ Created a cold storage wallet `WEBD$gCpXBKwTGPJ+A2HpEAN6FPsJaBPTtCzeez$` to increase security. \n\n';
resp +=
' \t ✅ Launched the 👻 Haunted Tower /game. Find out more in the dedicated channel: https://t.me/hauntedtower. \n\n';
resp +=
'*Try it out*: run /game in a group to compete against other players and earn rewards.';
const found_users = await user.model.findAll();
let sent_to_users = 0;
for (const found_user of found_users) {
if (!found_user.telegram_id) {
continue;
}
// only me (@morion4000)
if (found_user.telegram_id !== '528354447') {
// continue;
}
console.log(found_user.id, found_user.telegram_username);
//continue;
try {
await bot.sendPhoto(
found_user.telegram_id,
'https://web.hauntedtower.com/assets/game/logo/telegram_banner.png',
{
//caption: 'No-loss /lottery. Weekly prizes.',
}
);
await bot.sendMessage(found_user.telegram_id, resp, {
parse_mode: 'Markdown',
disable_web_page_preview: true,
disable_notification: true,
});
sent_to_users++;
} catch (error) {
console.error(error.message || error);
}
console.log(`sent to users: ${sent_to_users}/${found_users.length}`);
// To avoid getting blocked by Telegram
// https://core.telegram.org/bots/faq#my-bot-is-hitting-limits-how-do-i-avoid-this
await sleep(2000);
}
})();