Class: Tegawa::Bot
- Inherits:
-
Object
- Object
- Tegawa::Bot
- Defined in:
- lib/tegawa/bot.rb
Instance Method Summary collapse
-
#initialize(token, channel_id) ⇒ Bot
constructor
A new instance of Bot.
- #run ⇒ Object
Constructor Details
#initialize(token, channel_id) ⇒ Bot
Returns a new instance of Bot.
7 8 9 10 11 12 13 14 15 |
# File 'lib/tegawa/bot.rb', line 7 def initialize(token, channel_id) @token = token @channel_id = channel_id @queue = Tegawa.queue @logger = Tegawa.logger @bot = Telegram::Bot::Client.new(@token) @logger.info "Ready to forward messages to channel: #{@channel_id}" end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/tegawa/bot.rb', line 17 def run # FIXME: needs a thread pool to stop flooding while ( = @queue.pop) @logger.info "Forwarding message to telegram" @bot.api.(chat_id: @channel_id, text: ) end end |