1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-08-28 15:26:18 +03:00

Extract methods in UpdatesPoller

Этот коммит содержится в:
Max Melentiev
2018-02-02 10:37:45 +03:00
родитель eb24816e1e
Коммит 06253c940e

Просмотреть файл

@@ -41,19 +41,25 @@ module Telegram
def start
return if running
@running = true
log { 'Started bot poller.' }
while running
begin
updates = fetch_updates
process_updates(updates) if updates && updates.any?
rescue Interrupt
@running = false
end
begin
@running = true
log { 'Started bot poller.' }
run
rescue Interrupt
nil # noop
ensure
@running = false
end
log { 'Stoped polling bot updates.' }
end
def run
while running
updates = fetch_updates
process_updates(updates) if updates && updates.any?
end
end
# Method to stop poller from other thread.
def stop
return unless running