-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.rb
30 lines (27 loc) · 975 Bytes
/
bot.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
# frozen_string_literal: true
require_relative 'lib/telegram_github_changes_bot'
changes_bot = TelegramGithubChangesBot.new
Telegram::Bot::Client.run(changes_bot.config[:telegram_bot_token]) do |bot|
bot.listen do |event|
next unless changes_bot.text_command?(event)
changes_bot.log_message_receive(event)
case event.text
when %r{/get_changes.*}
text = ''
changes_bot.repos.each do |cur_repo|
cur_repo.refs_from_message(event.text)
text += cur_repo.link_to_changes
end
text = 'There is no changes for specified versions' if text.empty?
bot.api.send_message(chat_id: event.chat.id,
text:,
parse_mode: 'html')
when '/help'
bot.api.send_message(chat_id: event.chat.id,
text: changes_bot.help_message,
parse_mode: 'html')
else
changes_bot.log_unknown_command(event)
end
end
end