Class: TelegramMeetupBot::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/telegram_meetup_bot/client.rb

Constant Summary collapse

TIMEOUT =
1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Client

Returns a new instance of Client.



7
8
9
# File 'lib/telegram_meetup_bot/client.rb', line 7

def initialize(token)
  @token = token
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



5
6
7
# File 'lib/telegram_meetup_bot/client.rb', line 5

def token
  @token
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/telegram_meetup_bot/client.rb', line 11

def run
  Telegram::Bot::Client.run(token) do |bot|
    bot.enable_botan!(botan_key) if botan_key
    bot.listen do |message|
      process_message(bot, message) if message.text
    end
  end
rescue Telegram::Bot::Exceptions::ResponseError => e
  write_log_and_sleep(e)
  retry # run again on telegram server error
end