lib/telegram/bot/client.rb in telegram-bot-ruby-0.3.5 vs lib/telegram/bot/client.rb in telegram-bot-ruby-0.3.6

- old
+ new

@@ -21,10 +21,14 @@ def run yield self end def listen(&block) - loop { fetch_updates(&block) } + logger.info('Starting bot') + running = true + Signal.trap('INT') { running = false } + fetch_updates(&block) while running + exit end def fetch_updates response = api.getUpdates(offset: offset, timeout: timeout) return unless response['ok']