зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-04 02:05:52 +03:00
botan.io tracker
Этот коммит содержится в:
33
lib/telegram/bot/updates_controller/botan.rb
Обычный файл
33
lib/telegram/bot/updates_controller/botan.rb
Обычный файл
@@ -0,0 +1,33 @@
|
||||
module Telegram
|
||||
module Bot
|
||||
class UpdatesController
|
||||
# Helpers for botan.io metrics.
|
||||
module Botan
|
||||
class MissingFrom < Error; end
|
||||
|
||||
protected
|
||||
|
||||
def botan
|
||||
@botan ||= bot.try!(:botan)
|
||||
end
|
||||
|
||||
# Track custom event for user taken from `from` field:
|
||||
#
|
||||
# botan_track :my_event, {data: :val}
|
||||
#
|
||||
def botan_track(event, data = {})
|
||||
raise MissingFrom, 'Can not track without user' unless from
|
||||
botan.try! { |x| x.track(event, from['id'], data) }
|
||||
end
|
||||
|
||||
# Track current action and payload for current user. Best used with `before_action`:
|
||||
#
|
||||
# before_action :botan_track_action
|
||||
#
|
||||
def botan_track_action
|
||||
botan_track(action_name, payload)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Ссылка в новой задаче
Block a user