-
Notifications
You must be signed in to change notification settings - Fork 2
/
announce_update.rb
41 lines (36 loc) · 1.37 KB
/
announce_update.rb
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
load 'Rakefile'
updates = []
updates << 'latest updates:'
updates << '- Biduan dilemahin jadi cuma bisa 1x selamat dari serangan serigala. Soalnya lumayan banyak yang pake peran itu, imba'
updates << ''
updates << "- <a href='https://telegram.me/lycantulul_board'>Klik sini untuk join channel berisi update dari Lycantulul</a>"
updates << "- <a href='https://github.com/tulul/lycantulul_bot'>Klik sini kalo mau saran/lapor bug/kontribusi/dll (github)</a>"
updates << "- <a href='https://storebot.me/bot/lycantulul_bot'>Klik sini kalo mau ngasih rating/review (storebot)</a>"
updates << "- <a href='https://telegram.me/lycantulul'>Klik sini kalo grup kalian sepi dan pengen main bareng di grup publik</a>"
updates = updates.join("\n")
groups = Lycantulul::Game.all.map(&:group_id).uniq
puts "TARGET: #{groups.count}"
success = 0
failure = 0
Telegram::Bot::Client.run($token) do |bot|
groups.each do |g|
begin
bot.api.send_message(chat_id: g, text: updates, parse_mode: 'HTML', disable_web_page_preview: true)
success += 1
sleep(0.05)
rescue StandardError => e
failure += 1
puts e.message
if e.message =~ /400/
r = Lycantulul::Group.find_by(group_id: g)
r && r.destroy
end
ensure
if (success + failure) % 50 == 0
puts "#{success}/#{failure}"
end
end
end
end
puts "OK: #{success}"
puts "NO: #{failure}"