Class: Mutx::Support::TelegramSender
- Inherits:
-
Object
- Object
- Mutx::Support::TelegramSender
- Defined in:
- lib/mutx/support/telegram_sender.rb
Class Method Summary collapse
- .run_client ⇒ Object
-
.send_message(chat_id, message, parse_mode = nil) ⇒ Object
Send a message to the given group.
Instance Method Summary collapse
-
#initialize(token = nil, chat_id) ⇒ TelegramSender
constructor
A new instance of TelegramSender.
-
#send_message(message) ⇒ Object
Send a message to the given group.
Constructor Details
#initialize(token = nil, chat_id) ⇒ TelegramSender
Returns a new instance of TelegramSender.
7 8 9 10 |
# File 'lib/mutx/support/telegram_sender.rb', line 7 def initialize token=nil, chat_id @token = token || Configuration.telegram_token @chat_id = chat_id end |
Class Method Details
.run_client ⇒ Object
32 33 34 35 36 |
# File 'lib/mutx/support/telegram_sender.rb', line 32 def self.run_client Telegram::Bot::Client.run(Configuration.telegram_token) do |bot| yield bot end end |
.send_message(chat_id, message, parse_mode = nil) ⇒ Object
Send a message to the given group
26 27 28 29 30 |
# File 'lib/mutx/support/telegram_sender.rb', line 26 def self. chat_id, , parse_mode=nil Telegram::Bot::Client.run(Configuration.telegram_token) do |bot| bot.api.(chat_id: chat_id, text: , parse_mode:parse_mode) end end |
Instance Method Details
#send_message(message) ⇒ Object
Send a message to the given group
16 17 18 19 20 |
# File 'lib/mutx/support/telegram_sender.rb', line 16 def Telegram::Bot::Client.run(@token) do |bot| bot.api.(chat_id: @chat_id, text: ) end end |