зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-08-28 15:26:18 +03:00
Extract methods in UpdatesPoller
Этот коммит содержится в:
@@ -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
|
||||
|
||||
Ссылка в новой задаче
Block a user