lib/telegram/bot/config_methods.rb in telegram-bot-0.9.0 vs lib/telegram/bot/config_methods.rb in telegram-bot-0.10.0
- old
+ new
@@ -18,11 +18,11 @@
# It's enabled by default in Rails dev environment and `rake telegram:bot:poller`
# task. Use `BOT_POLLER_MODE=true` envvar to set it manually.
def bot_poller_mode?
return @bot_poller_mode if defined?(@bot_poller_mode)
@bot_poller_mode = ENV.fetch('BOT_POLLER_MODE') do
- Rails.env.development? if defined?(Rails)
+ Rails.env.development? if defined?(Rails.env)
end
end
# Hash of bots made with bots_config.
def bots
@@ -45,10 +45,10 @@
# from `secrets.yml` merging `telegram['bot']` at `:default` key.
#
# Can be overwritten with .bots_config=
def bots_config
@bots_config ||=
- if defined?(Rails)
+ if defined?(Rails.application)
telegram_config = Rails.application.secrets[:telegram] || {}
(telegram_config['bots'] || {}).symbolize_keys.tap do |config|
default = telegram_config['bot']
config[:default] = default if default
end