class Message

Monday, August 24 2020 EAT

This object represents a message.

Public Instance Methods

animation() click to toggle source

Optional. Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set. Returns Animation object

# File lib/objects/message.rb, line 159
def animation
  an = @message.animation
  return Animation.new(an) if an

  false
end
animation_msg?() click to toggle source
# File lib/objects/message.rb, line 305
def animation_msg?
  @message.animation ? true : false
end
audio() click to toggle source

Optional. message is an Audio file, information about the file.

# File lib/objects/message.rb, line 167
def audio
  ad = @message.audio
  return Audio.new(ad) if ad

  false
end
audio_msg?() click to toggle source
# File lib/objects/message.rb, line 289
def audio_msg?
  @message.audio ? true : false
end
author_signature() click to toggle source

Optional. Signature of the post author for messages in channels.

# File lib/objects/message.rb, line 129
def author_signature
  @message.author_signature
end
caption() click to toggle source

Optional. Caption for the animation, audio, document, photo, video or voice, 0-1024 characters.

# File lib/objects/message.rb, line 233
def caption
  @message.caption
end
caption_entities() click to toggle source

Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption.

# File lib/objects/message.rb, line 239
def caption_entities
  c_entitys = @message.caption_entities
  if c_entitys.empty?
    return false
  end

  ary_ent = []
  c_entitys.each do |ent|
    ary_ent << MessageEntity.new(ent)
  end
  ary_ent
end
chat() click to toggle source

Conversation the message belongs to. Returns Chat object

# File lib/objects/message.rb, line 49
def chat
  Chat.new(@message.chat)
end
contact() click to toggle source

Optional. Message is a shared contact, information about the contact.

# File lib/objects/message.rb, line 253
def contact
  kontakt = @message.contact
  return Contact.new(kontakt) if kontakt

  false
end
contact_msg?() click to toggle source
# File lib/objects/message.rb, line 297
def contact_msg?
  @message.contact ? true : false
end
date() click to toggle source

TDate Object the message was sent in Unix time

# File lib/objects/message.rb, line 43
def date
  return TDate.new(@message.date)
end
delete_chat_photo?() click to toggle source
# File lib/objects/message.rb, line 361
def delete_chat_photo?
  @message.delete_chat_photo ? true : false
end
dice() click to toggle source

Optional. Message is a Dice with random value from 1 to 6.

# File lib/objects/message.rb, line 261
def dice
  dis = @message.dice
  return Dice.new(dis) if dis

  false
end
document() click to toggle source

Optional. message is a general file, information about the file. Returns Document object.

# File lib/objects/message.rb, line 176
def document
  doc = @message.document
  return Document.new(doc) if doc

  false
end
document_msg?() click to toggle source
# File lib/objects/message.rb, line 293
def document_msg?
  @message.document ? true : false
end
edit_date() click to toggle source

Optional. Retuns TDate object.

# File lib/objects/message.rb, line 118
def edit_date
  TDate.new(@messag.edit_date)
end
entities() click to toggle source

Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text. Returns array of MessageEntity object

# File lib/objects/message.rb, line 142
def entities
  ary_entity = []
  entitys = @message.entities
  if entitys.empty?
    return false
  end

  entitys.each do |ent|
    ary_entity << MessageEntity.new(ent)
  end
  ary_entity
end
forward_date() click to toggle source

Optional. For forwarded messages, date the original message was sent in Unix time. Returns TDate object.

# File lib/objects/message.rb, line 93
def forward_date
  TDate.new(@message.forward_date)
end
forward_from() click to toggle source

Optional. For forwarded messages, sender of the original message. Returns Chat object

# File lib/objects/message.rb, line 55
def forward_from
  f_from = @message.forward_from
  return User.new(f_from) if f_from

  false
end
forward_from_chat() click to toggle source

Optional. For messages forwarded from channels, information about the original channel. Returns Chat object.

# File lib/objects/message.rb, line 65
def forward_from_chat
  ff_chat = @message.forward_from_chat
  return Chat.new(ff_chat) if ff_chat

  false
end
forward_from_chat?() click to toggle source
# File lib/objects/message.rb, line 369
def forward_from_chat?
  @message.forward_from_chat ? true : false
end
forward_from_message_id() click to toggle source

Optional. For messages forwarded from channels, identifier of the original message in the channel.

# File lib/objects/message.rb, line 74
def forward_from_message_id
  @message.forward_from_message_id
end
forward_msg?() click to toggle source
# File lib/objects/message.rb, line 301
def forward_msg?
  (@update.forward_from) or (@update.forward_from_chat) ? true : false
end
forward_sender_name() click to toggle source

Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages.

# File lib/objects/message.rb, line 86
def forward_sender_name
  @message.forward_sender_name
end
forward_signature() click to toggle source

Optional. For messages forwarded from channels, signature of the post author if present.

# File lib/objects/message.rb, line 80
def forward_signature
  @message.forward_signature
end
from() click to toggle source

Optional. Sender, empty for messages sent to channels. Returns User object.

# File lib/objects/message.rb, line 35
def from
  frm = @message.from
  return User.new(frm) if frm

  false
end
game() click to toggle source

Optional. Message is a Game, information about the game.

# File lib/objects/message.rb, line 269
def game
  gam = @message.game
  return Game.new(gam) if gam

  false
end
game_msg?() click to toggle source
# File lib/objects/message.rb, line 325
def game_msg?
  @message.game ? true : false
end
has_entities?() click to toggle source
# File lib/objects/message.rb, line 373
def has_entities?
  @message.entities.empty? ? false : true
end
left_chat_member?() click to toggle source
# File lib/objects/message.rb, line 345
def left_chat_member?
  @message.left_chat_member ? true : false
end
location_msg?() click to toggle source
# File lib/objects/message.rb, line 337
def location_msg?
  @message.location ? true : false
end
media_group_id() click to toggle source

Optional. The unique identifier of a media message group this message belongs to.

# File lib/objects/message.rb, line 124
def media_group_id
  @message.media_group_id
end
message_id() click to toggle source

Unique message identifier inside the chat.

# File lib/objects/message.rb, line 29
def message_id
  @message.message_id
end
new_chat_member?() click to toggle source
# File lib/objects/message.rb, line 341
def new_chat_member?
  @message.new_chat_member ? true : false
end
new_chat_photo?() click to toggle source
# File lib/objects/message.rb, line 353
def new_chat_photo?
  @message.new_chat_photo ? true : false
end
new_chat_title?() click to toggle source
# File lib/objects/message.rb, line 349
def new_chat_title?
  @message.new_chat_title ? true : false
end
photo() click to toggle source

Optional. message is a Photo, available sizes of the photo. returns array of PhotoSize object

# File lib/objects/message.rb, line 185
def photo
  poto = @message.photo
  if poto.empty?
    return false
  end

  e_photo = []
  poto.each do
    e_photo << PhotoSize.new(e_photo)
  end
  e_photo
end
photo_msg?() click to toggle source
# File lib/objects/message.rb, line 309
def photo_msg?
  @message.photo.empty? ? false : true
end
pinned_msg?() click to toggle source
# File lib/objects/message.rb, line 357
def pinned_msg?
  @message.pinned_message ? true : false
end
poll_msg?() click to toggle source
# File lib/objects/message.rb, line 329
def poll_msg?
  @message.poll ? true : false
end
reply_markup?() click to toggle source
# File lib/objects/message.rb, line 365
def reply_markup?
  @message.reply_markup ? true : false
end
reply_msg?() click to toggle source

returns true if the update is for replied msg

# File lib/objects/message.rb, line 281
def reply_msg?
  @message.reply_to_message ? true : false
end
reply_to_message() click to toggle source

Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. Returns Message object

# File lib/objects/message.rb, line 101
def reply_to_message
  r_t_msg = @message.reply_to_message
  return Message.new(r_t_msg) if r_t_msg

  false
end
sticker() click to toggle source

Optional. Message is a sticker, information about the sticker returns Sticker object

# File lib/objects/message.rb, line 200
def sticker
  stiker = @message.sticker
  return Sticker.new(stiker) if stiker

  false
end
sticker_msg?() click to toggle source
# File lib/objects/message.rb, line 321
def sticker_msg?
  @message.sticker ? true : false
end
text() click to toggle source

Optional. For text messages, the actual UTF-8 text of the message, 0-4096 characters

# File lib/objects/message.rb, line 135
def text
  @message.text
end
text_msg?() click to toggle source
# File lib/objects/message.rb, line 276
def text_msg?
  text ? true : false
end
venue_msg?() click to toggle source
# File lib/objects/message.rb, line 333
def venue_msg?
  @message.venue ? true : false
end
via_bot() click to toggle source

Optional. Bot through which the message was sent. Returns User object.

# File lib/objects/message.rb, line 110
def via_bot
  v_bot = @message.via_bot
  return User.new(v_bot) if v_bot

  false
end
video() click to toggle source

Optional. Message is a Video, information about the video.

# File lib/objects/message.rb, line 208
def video
  vd = @message.video
  return Video.new(vd) if vd

  false
end
video_msg?() click to toggle source
# File lib/objects/message.rb, line 285
def video_msg?
  @message.video ? true : false
end
video_note() click to toggle source

Optional. Message is a VideoNote, information about the video message.

# File lib/objects/message.rb, line 216
def video_note
  vnot = @message.video_note
  return VideoNote.new(vnot) if vnot

  false
end
video_note_msg?() click to toggle source
# File lib/objects/message.rb, line 317
def video_note_msg?
  @message.video_note ? true : false
end
voice() click to toggle source

Optional. message is a Voice message, information about the file.

# File lib/objects/message.rb, line 224
def voice
  vc = @message.voice
  return Voice.new(vc) if vc

  false
end
voice_msg?() click to toggle source
# File lib/objects/message.rb, line 313
def voice_msg?
  @message.voice ? true : false
end