зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-04 10:15:50 +03:00
v0.1.0
Этот коммит содержится в:
38
lib/telegram/bot/updates_controller/log_subscriber.rb
Обычный файл
38
lib/telegram/bot/updates_controller/log_subscriber.rb
Обычный файл
@@ -0,0 +1,38 @@
|
||||
require 'active_support/log_subscriber'
|
||||
|
||||
module Telegram
|
||||
class Bot
|
||||
class UpdatesController
|
||||
class LogSubscriber < ActiveSupport::LogSubscriber
|
||||
def start_processing(event)
|
||||
info do
|
||||
payload = event.payload
|
||||
"Processing by #{payload[:controller]}##{payload[:action]}\n" \
|
||||
" Update: #{payload[:update].to_json}"
|
||||
end
|
||||
end
|
||||
|
||||
def process_action(event)
|
||||
info do
|
||||
payload = event.payload
|
||||
additions = UpdatesController.log_process_action(payload)
|
||||
message = "Completed in #{event.duration.round}ms"
|
||||
message << " (#{additions.join(' | ')})" unless additions.blank?
|
||||
message
|
||||
end
|
||||
end
|
||||
|
||||
def reply_with(event)
|
||||
info { "Replied with #{event.payload[:type]}" }
|
||||
end
|
||||
|
||||
def halted_callback(event)
|
||||
info { "Filter chain halted at #{event.payload[:filter].inspect}" }
|
||||
end
|
||||
|
||||
delegate :logger, to: UpdatesController
|
||||
attach_to 'updates_controller.bot.telegram'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Ссылка в новой задаче
Block a user