Module: Telegram::Bottable
- Included in:
- Telegram
- Defined in:
- lib/telegram/bottable.rb
Instance Attribute Summary collapse
-
#bot_poller_mode ⇒ Object
writeonly
Keep this setting here, so we can avoid loading Bot::UpdatesPoller when polling is disabled.
-
#bots_config ⇒ Object
Returns config for .bots method.
Instance Method Summary collapse
-
#bot ⇒ Object
Default bot.
-
#bot_poller_mode? ⇒ Boolean
It just tells routes helpers whether to add routed bots to Bot::UpdatesPoller, so their config will be available by bot key in Bot::UpdatesPoller.start.
-
#bots ⇒ Object
Hash of bots made with bots_config.
Instance Attribute Details
#bot_poller_mode=(value) ⇒ Object (writeonly)
Keep this setting here, so we can avoid loading Bot::UpdatesPoller when polling is disabled.
8 9 10 |
# File 'lib/telegram/bottable.rb', line 8 def bot_poller_mode=(value) @bot_poller_mode = value end |
#bots_config ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/telegram/bottable.rb', line 32 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 end |
Instance Method Details
#bot ⇒ Object
Default bot.
24 25 26 |
# File 'lib/telegram/bottable.rb', line 24 def bot @bot ||= bots[:default] end |
#bot_poller_mode? ⇒ Boolean
It just tells routes helpers whether to add routed bots to Bot::UpdatesPoller, so their config will be available by bot key in Bot::UpdatesPoller.start.
13 14 15 16 |
# File 'lib/telegram/bottable.rb', line 13 def bot_poller_mode? return @bot_poller_mode if defined?(@bot_poller_mode) Rails.env.development? if defined?(Rails) end |
#bots ⇒ Object
Hash of bots made with bots_config.
19 20 21 |
# File 'lib/telegram/bottable.rb', line 19 def bots @bots ||= bots_config.transform_values(&Bot.method(:wrap)) end |