Class: TelegramSupportBot::Adapters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/telegram_support_bot/adapters/base.rb

Direct Known Subclasses

TelegramBot, TelegramBotRuby

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Base

Returns a new instance of Base.



9
10
11
12
# File 'lib/telegram_support_bot/adapters/base.rb', line 9

def initialize(**options)
  @options = options
  setup(options)
end

Instance Attribute Details

#botObject (readonly)

Returns the value of attribute bot.



7
8
9
# File 'lib/telegram_support_bot/adapters/base.rb', line 7

def bot
  @bot
end

Instance Method Details

#forward_message(from_chat_id:, chat_id:, message_id:) ⇒ Object



34
35
36
# File 'lib/telegram_support_bot/adapters/base.rb', line 34

def forward_message(from_chat_id:, chat_id:, message_id:)
  # forward messages to the support chat
end

#on_message(&block) ⇒ Object



38
39
40
# File 'lib/telegram_support_bot/adapters/base.rb', line 38

def on_message(&block)
  # Implementation to register a block to be called on new messages
end

#send_media(chat_id:, type:, media:, **options) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/telegram_support_bot/adapters/base.rb', line 22

def send_media(chat_id:, type:, media:, **options)
  method = "send_#{type}"
  args = { chat_id: chat_id, **options }
  args[type] = media

  if respond_to?(method, true)
    send(method, **args)
  else
    raise ArgumentError, "Unsupported media type: #{type}"
  end
end

#send_message(chat_id:, text:) ⇒ Object



18
19
20
# File 'lib/telegram_support_bot/adapters/base.rb', line 18

def send_message(chat_id:, text:)
  # Implementation using the telegram-bot gem
end

#setup(options) ⇒ Object



14
15
16
# File 'lib/telegram_support_bot/adapters/base.rb', line 14

def setup(options)
  # Setup based on options, to be overridden by child classes if necessary
end