class Message
Is a representation of Telegrams Message
object
Attributes
chat[R]
text[R]
Public Class Methods
from_hash(message)
click to toggle source
# File lib/telegram/message.rb, line 7 def self.from_hash(message) return nil unless message.is_a? Hash chat = Chat.from_hash message['chat'] from = User.from_hash message['from'] Message.new(message_id: message['message_id'], from: from, chat: chat, text: message['text']) end
new(message_id:, from:nil, chat:, text:)
click to toggle source
# File lib/telegram/message.rb, line 16 def initialize(message_id:, from:nil, chat:, text:) @message_id = message_id @from = from @chat = chat @text = text end
Public Instance Methods
contains_command?(command)
click to toggle source
# File lib/telegram/message.rb, line 23 def contains_command?(command) if command.is_a?(Symbol) && text.split(' ').first.eql?("/#{command}") true elsif text.start_with?(command.to_s) true else false end end
reply(text, opts = {})
click to toggle source
# File lib/telegram/message.rb, line 33 def reply(text, opts = {}) chat.reply text, opts.merge(reply_to_message_id: @message_id) end