Module: TelegramSupportBot
- Defined in:
- lib/telegram_support_bot/adapter_factory.rb,
lib/telegram_support_bot.rb,
lib/telegram_support_bot/version.rb,
lib/telegram_support_bot/adapters/base.rb,
lib/telegram_support_bot/configuration.rb,
lib/telegram_support_bot/auto_away_scheduler.rb,
lib/telegram_support_bot/adapters/telegram_bot.rb,
lib/telegram_support_bot/adapters/telegram_bot_ruby.rb
Overview
lib/telegram_support_bot/adapter_factory.rb
Defined Under Namespace
Modules: AdapterFactory, Adapters Classes: AutoAwayScheduler, Configuration
Constant Summary collapse
- VERSION =
"0.1.06"
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
-
.message_chat_id ⇒ Object
readonly
Returns the value of attribute message_chat_id.
Class Method Summary collapse
-
.adapter ⇒ Object
Lazily builds and returns the adapter based on the current configuration.
-
.configure {|configuration| ... } ⇒ Object
Provides a method to configure the gem.
- .process_update(update) ⇒ Object
-
.reset_adapter! ⇒ Object
Reset the adapter instance (useful for testing or reconfiguration).
- .scheduler ⇒ Object
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
13 14 15 |
# File 'lib/telegram_support_bot.rb', line 13 def configuration @configuration end |
.message_chat_id ⇒ Object (readonly)
Returns the value of attribute message_chat_id.
14 15 16 |
# File 'lib/telegram_support_bot.rb', line 14 def @message_chat_id end |
Class Method Details
.adapter ⇒ Object
Lazily builds and returns the adapter based on the current configuration. This method initializes the adapter when it’s first called.
24 25 26 |
# File 'lib/telegram_support_bot.rb', line 24 def adapter @adapter ||= AdapterFactory.build(configuration.adapter, configuration.) end |
.configure {|configuration| ... } ⇒ Object
Provides a method to configure the gem.
17 18 19 20 |
# File 'lib/telegram_support_bot.rb', line 17 def configure self.configuration ||= Configuration.new yield(configuration) if block_given? end |
.process_update(update) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/telegram_support_bot.rb', line 32 def process_update(update) # Handle different types of updates if update['message'] # Process standard messages (update['message']) elsif update['my_chat_member'] # Handle the bot being added to or removed from a chat handle_my_chat_member_update(update['my_chat_member']) # Add other update types as needed else # Log or handle unknown update types puts "Received an unknown type of update: #{update}" end end |
.reset_adapter! ⇒ Object
Reset the adapter instance (useful for testing or reconfiguration).
182 183 184 |
# File 'lib/telegram_support_bot.rb', line 182 def self.reset_adapter! @adapter = nil end |
.scheduler ⇒ Object
28 29 30 |
# File 'lib/telegram_support_bot.rb', line 28 def scheduler @scheduler ||= AutoAwayScheduler.new(adapter, configuration) end |