Module: TeleRb::MessageMethods

Included in:
TelegramBot
Defined in:
lib/telerb/methods/message_methods.rb

Overview

Message Methods

Instance Method Summary collapse

Instance Method Details

#forward_message(from_chat_id, to_chat_id, message_id) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/telerb/methods/message_methods.rb', line 15

def forward_message(from_chat_id, to_chat_id, message_id)
  CLIENT.post(@config.base_uri("forwardMessage"),
              { chat_id: to_chat_id, from_chat_id: from_chat_id, message_id: message_id })
  "Forwarding was then done successfully!"
rescue StandardError => e
  puts "Error forwarding message: #{e.message}"
  nil
end

#send_location(chat_id, latitude, longitude, reply_to_message_id = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/telerb/methods/message_methods.rb', line 24

def send_location(chat_id, latitude, longitude, reply_to_message_id = nil)
  CLIENT.post(@config.base_uri("sendLocation"),
              { chat_id: chat_id, latitude: latitude, longitude: longitude,
                reply_to_message_id: reply_to_message_id })
  "Location Sent with success!"
rescue StandardError => e
  puts "Error when sending Location: #{e.message}"
  nil
end

#send_message(chat_id, text, reply_to_message_id = nil) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/telerb/methods/message_methods.rb', line 6

def send_message(chat_id, text, reply_to_message_id = nil)
  CLIENT.post(@config.base_uri("sendMessage"),
              { chat_id: chat_id, text: text, reply_to_message_id: reply_to_message_id })
  "Message sent successfully!"
rescue StandardError => e
  puts "Error sending message: #{e.message}"
  nil
end