Class: TelegramSupportBot::Adapters::TelegramBot

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

Instance Attribute Summary

Attributes inherited from Base

#bot

Instance Method Summary collapse

Methods inherited from Base

#on_message, #send_media, #setup

Constructor Details

#initialize(**options) ⇒ TelegramBot

Returns a new instance of TelegramBot.



8
9
10
11
# File 'lib/telegram_support_bot/adapters/telegram_bot.rb', line 8

def initialize(**options)
  super
  @bot = Telegram::Bot::Client.new(@options[:token], @options[:username])
end

Instance Method Details

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



46
47
48
49
50
51
52
# File 'lib/telegram_support_bot/adapters/telegram_bot.rb', line 46

def forward_message(from_chat_id:, chat_id:, message_id:)
  @bot.forward_message(
    chat_id:      chat_id,
    from_chat_id: from_chat_id,
    message_id:   message_id
  )
end

#send_audio(chat_id:, audio:, **options) ⇒ Object

Handles sending audio messages



32
33
34
# File 'lib/telegram_support_bot/adapters/telegram_bot.rb', line 32

def send_audio(chat_id:, audio:, **options)
  @bot.send_audio(chat_id: chat_id, audio: audio, **options)
end

#send_document(chat_id:, document:, **options) ⇒ Object



27
28
29
# File 'lib/telegram_support_bot/adapters/telegram_bot.rb', line 27

def send_document(chat_id:, document:, **options)
  @bot.send_document(chat_id: chat_id, document: document, **options)
end

#send_message(chat_id:, text:, **options) ⇒ Object Also known as: send_text



13
14
15
# File 'lib/telegram_support_bot/adapters/telegram_bot.rb', line 13

def send_message(chat_id:, text:, **options)
  @bot.send_message(chat_id: chat_id, text: text, **options)
end

#send_photo(chat_id:, photo:, **options) ⇒ Object



19
20
21
# File 'lib/telegram_support_bot/adapters/telegram_bot.rb', line 19

def send_photo(chat_id:, photo:, **options)
  @bot.send_photo(chat_id: chat_id, photo: photo, **options)
end

#send_sticker(chat_id:, sticker:, **options) ⇒ Object

Handles sending sticker messages



42
43
44
# File 'lib/telegram_support_bot/adapters/telegram_bot.rb', line 42

def send_sticker(chat_id:, sticker:, **options)
  @bot.send_sticker(chat_id: chat_id, sticker: sticker, **options)
end

#send_video(chat_id:, video:, **options) ⇒ Object



23
24
25
# File 'lib/telegram_support_bot/adapters/telegram_bot.rb', line 23

def send_video(chat_id:, video:, **options)
  @bot.send_video(chat_id: chat_id, video: video, **options)
end

#send_voice(chat_id:, voice:, **options) ⇒ Object

Handles sending audio messages



37
38
39
# File 'lib/telegram_support_bot/adapters/telegram_bot.rb', line 37

def send_voice(chat_id:, voice:, **options)
  @bot.send_voice(chat_id: chat_id, voice: voice, **options)
end