1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-09-03 09:46:17 +03:00
Этот коммит содержится в:
Max Melentiev
2016-05-19 16:29:01 +03:00
родитель 85ff07de9b
Коммит 71f736e0a2
14 изменённых файлов: 421 добавлений и 15 удалений

Просмотреть файл

@@ -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.