зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-03 09:46:17 +03:00
Async requests with ActiveJob
Этот коммит содержится в:
@@ -26,7 +26,9 @@ module Telegram
|
||||
|
||||
# Hash of bots made with bots_config.
|
||||
def bots
|
||||
@bots ||= bots_config.transform_values(&Client.method(:wrap))
|
||||
@bots ||= bots_config.each_with_object({}) do |(id, config), h|
|
||||
h[id] = Client.wrap(config, id: id)
|
||||
end
|
||||
end
|
||||
|
||||
# Default bot.
|
||||
@@ -44,12 +46,16 @@ module Telegram
|
||||
#
|
||||
# Can be overwritten with .bots_config=
|
||||
def bots_config
|
||||
return @bots_config if @bots_config
|
||||
telegram_config = Rails.application.secrets[:telegram]
|
||||
(telegram_config['bots'] || {}).symbolize_keys.tap do |config|
|
||||
default = telegram_config['bot']
|
||||
config[:default] = default if default
|
||||
end
|
||||
@bots_config ||=
|
||||
if defined?(Rails)
|
||||
telegram_config = Rails.application.secrets[:telegram] || {}
|
||||
(telegram_config['bots'] || {}).symbolize_keys.tap do |config|
|
||||
default = telegram_config['bot']
|
||||
config[:default] = default if default
|
||||
end
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
# Resets all cached bots and their configs.
|
||||
|
||||
Ссылка в новой задаче
Block a user