зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-05 18:45:51 +03:00
Extract methods in UpdatesPoller
Этот коммит содержится в:
@@ -41,19 +41,25 @@ module Telegram
|
|||||||
|
|
||||||
def start
|
def start
|
||||||
return if running
|
return if running
|
||||||
@running = true
|
begin
|
||||||
log { 'Started bot poller.' }
|
@running = true
|
||||||
while running
|
log { 'Started bot poller.' }
|
||||||
begin
|
run
|
||||||
updates = fetch_updates
|
rescue Interrupt
|
||||||
process_updates(updates) if updates && updates.any?
|
nil # noop
|
||||||
rescue Interrupt
|
ensure
|
||||||
@running = false
|
@running = false
|
||||||
end
|
|
||||||
end
|
end
|
||||||
log { 'Stoped polling bot updates.' }
|
log { 'Stoped polling bot updates.' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def run
|
||||||
|
while running
|
||||||
|
updates = fetch_updates
|
||||||
|
process_updates(updates) if updates && updates.any?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Method to stop poller from other thread.
|
# Method to stop poller from other thread.
|
||||||
def stop
|
def stop
|
||||||
return unless running
|
return unless running
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user