-
Notifications
You must be signed in to change notification settings - Fork 3
/
telegram_router.rb
52 lines (41 loc) · 1.37 KB
/
telegram_router.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
42
43
44
45
46
47
48
49
50
51
52
require_relative 'telegram_responders/photo'
require_relative 'telegram_responders/stats'
require_relative 'telegram_responders/proof'
require_relative 'telegram_responders/set_invite_link'
class TelegramRouter
attr_reader :message, :client
def initialize(message, client)
@message = message
@client = client
end
def respond!
(message.photo.any? && photo_response) || text_response
end
def photo_response
if response = TelegramResponder::Photo.new(message).respond!
BotLogger.info("New Tiemur! #{message.from.username}, #{response}")
return response
end
false
end
def text_response
case message.text
when /\A\/set_invite_link/
if response = TelegramResponder::SetInviteLink.new(message, client: client).respond!
BotLogger.info("Invite link set. #{message.from.username}, #{response}")
return response
end
when '/proof', '/proof@TiemurBot'
if response = TelegramResponder::Proof.new(message).respond!
BotLogger.info("Tiemur proofs requested. #{message.from.username}, #{response}")
return response
end
when '/tiemur_stats', '/tiemur_stats@TiemurBot'
if response = TelegramResponder::Stats.new(message).respond!
BotLogger.info("Tiemur stats requested. #{message.from.username}, #{response}")
return response
end
end
false
end
end