Class: Message
- Inherits:
-
Object
- Object
- Message
- Defined in:
- lib/objects/message.rb
Overview
Monday
, August
24
2020
EAT
This object represents a message.
Instance Method Summary collapse
-
#animation ⇒ Object
Optional.
Message is an animation, information about the animation. - #animation_msg? ⇒ Boolean
-
#audio ⇒ Object
Optional
. - #audio_msg? ⇒ Boolean
-
#author_signature ⇒ Object
Optional.
Signature of the post author for messages in channels. -
#caption ⇒ Object
Optional
. -
#caption_entities ⇒ Object
Optional.
For messages with a caption, special entities like usernames, URLs, bot commands, etc. -
#chat ⇒ Object
Conversation the message belongs to.
-
#contact ⇒ Object
Optional
. - #contact_msg? ⇒ Boolean
-
#date ⇒ Object
TDate Object the message was sent in Unix time.
- #delete_chat_photo? ⇒ Boolean
-
#dice ⇒ Object
Optional
. -
#document ⇒ Object
Optional
. - #document_msg? ⇒ Boolean
-
#edit_date ⇒ Object
Optional
. -
#entities ⇒ Object
Optional.
For text messages, special entities like usernames, URLs, bot commands, etc. -
#forward_date ⇒ Object
Optional.
For forwarded messages, date the original message was sent in Unix time. -
#forward_from ⇒ Object
Optional.
For forwarded messages, sender of the original message. -
#forward_from_chat ⇒ Object
Optional.
For messages forwarded from channels, information about the original channel. - #forward_from_chat? ⇒ Boolean
-
#forward_from_message_id ⇒ Object
Optional.
For messages forwarded from channels, identifier of the original message in the channel. - #forward_msg? ⇒ Boolean
-
#forward_sender_name ⇒ Object
Optional
. -
#forward_signature ⇒ Object
Optional.
For messages forwarded from channels, signature of the post author if present. -
#from ⇒ Object
Optional.
Sender, empty for messages sent to channels. -
#game ⇒ Object
Optional
. - #game_msg? ⇒ Boolean
- #has_entities? ⇒ Boolean
-
#initialize(msg) ⇒ Message
constructor
:nodoc:.
- #left_chat_member? ⇒ Boolean
- #location_msg? ⇒ Boolean
-
#media_group_id ⇒ Object
Optional
. -
#message_id ⇒ Object
Unique message identifier inside the chat.
- #new_chat_member? ⇒ Boolean
- #new_chat_photo? ⇒ Boolean
- #new_chat_title? ⇒ Boolean
-
#photo ⇒ Object
Optional
. - #photo_msg? ⇒ Boolean
- #pinned_msg? ⇒ Boolean
- #poll_msg? ⇒ Boolean
- #reply_markup? ⇒ Boolean
-
#reply_msg? ⇒ Boolean
returns true if the update is for replied msg.
-
#reply_to_message ⇒ Object
Optional.
For replies, the original message. -
#sticker ⇒ Object
Optional.
Message is a sticker, information about the sticker returns Sticker object. - #sticker_msg? ⇒ Boolean
-
#text ⇒ Object
Optional
. - #text_msg? ⇒ Boolean
- #venue_msg? ⇒ Boolean
-
#via_bot ⇒ Object
Optional
. -
#video ⇒ Object
Optional.
Message is a Video, information about the video. - #video_msg? ⇒ Boolean
-
#video_note ⇒ Object
Optional.
Message is a VideoNote, information about the video message. - #video_note_msg? ⇒ Boolean
-
#voice ⇒ Object
Optional
. - #voice_msg? ⇒ Boolean
Constructor Details
#initialize(msg) ⇒ Message
:nodoc:
24 25 26 |
# File 'lib/objects/message.rb', line 24 def initialize(msg) # :nodoc: @message = msg end |
Instance Method Details
#animation ⇒ Object
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
159 160 161 162 163 164 |
# File 'lib/objects/message.rb', line 159 def animation an = @message.animation return Animation.new(an) if an false end |
#animation_msg? ⇒ Boolean
305 306 307 |
# File 'lib/objects/message.rb', line 305 def animation_msg? @message.animation ? true : false end |
#audio ⇒ Object
Optional
. message is an Audio file, information about the file.
167 168 169 170 171 172 |
# File 'lib/objects/message.rb', line 167 def audio ad = @message.audio return Audio.new(ad) if ad false end |
#audio_msg? ⇒ Boolean
289 290 291 |
# File 'lib/objects/message.rb', line 289 def audio_msg? @message.audio ? true : false end |
#author_signature ⇒ Object
Optional.
Signature of the post author for messages in channels.
129 130 131 |
# File 'lib/objects/message.rb', line 129 def @message. end |
#caption ⇒ Object
Optional
. Caption for the animation, audio, document, photo, video or voice, 0-1024 characters.
233 234 235 |
# File 'lib/objects/message.rb', line 233 def @message. end |
#caption_entities ⇒ Object
Optional.
For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption.
239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/objects/message.rb', line 239 def c_entitys = @message. if c_entitys.empty? return false end ary_ent = [] c_entitys.each do |ent| ary_ent << MessageEntity.new(ent) end ary_ent end |
#chat ⇒ Object
Conversation the message belongs to. Returns Chat object
49 50 51 |
# File 'lib/objects/message.rb', line 49 def chat Chat.new(@message.chat) end |
#contact ⇒ Object
Optional
. Message is a shared contact, information about the contact.
253 254 255 256 257 258 |
# File 'lib/objects/message.rb', line 253 def contact kontakt = @message.contact return Contact.new(kontakt) if kontakt false end |
#contact_msg? ⇒ Boolean
297 298 299 |
# File 'lib/objects/message.rb', line 297 def contact_msg? @message.contact ? true : false end |
#date ⇒ Object
TDate Object the message was sent in Unix time
43 44 45 |
# File 'lib/objects/message.rb', line 43 def date return TDate.new(@message.date) end |
#delete_chat_photo? ⇒ Boolean
361 362 363 |
# File 'lib/objects/message.rb', line 361 def delete_chat_photo? @message.delete_chat_photo ? true : false end |
#dice ⇒ Object
Optional
. Message is a Dice with random value from 1 to 6.
261 262 263 264 265 266 |
# File 'lib/objects/message.rb', line 261 def dice dis = @message.dice return Dice.new(dis) if dis false end |
#document ⇒ Object
Optional
. message is a general file, information about the file. Returns Document object.
176 177 178 179 180 181 |
# File 'lib/objects/message.rb', line 176 def document doc = @message.document return Document.new(doc) if doc false end |
#document_msg? ⇒ Boolean
293 294 295 |
# File 'lib/objects/message.rb', line 293 def document_msg? @message.document ? true : false end |
#edit_date ⇒ Object
Optional
. Retuns TDate object.
118 119 120 |
# File 'lib/objects/message.rb', line 118 def edit_date TDate.new(@messag.edit_date) end |
#entities ⇒ Object
Optional.
For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text. Returns array of MessageEntity object
142 143 144 145 146 147 148 149 150 151 152 153 |
# 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 ⇒ Object
Optional.
For forwarded messages, date the original message was sent in Unix time. Returns TDate object.
93 94 95 |
# File 'lib/objects/message.rb', line 93 def forward_date TDate.new(@message.forward_date) end |
#forward_from ⇒ Object
Optional.
For forwarded messages, sender of the original message. Returns Chat object
55 56 57 58 59 60 |
# 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 ⇒ Object
Optional.
For messages forwarded from channels, information about the original channel. Returns Chat object.
65 66 67 68 69 70 |
# 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? ⇒ Boolean
369 370 371 |
# File 'lib/objects/message.rb', line 369 def forward_from_chat? @message.forward_from_chat ? true : false end |
#forward_from_message_id ⇒ Object
Optional.
For messages forwarded from channels, identifier of the original message in the channel.
74 75 76 |
# File 'lib/objects/message.rb', line 74 def @message. end |
#forward_msg? ⇒ Boolean
301 302 303 |
# File 'lib/objects/message.rb', line 301 def forward_msg? (@update.forward_from) or (@update.forward_from_chat) ? true : false end |
#forward_sender_name ⇒ Object
Optional
. Sender’s name for messages forwarded from users who disallow adding a link to their account in forwarded messages.
86 87 88 |
# File 'lib/objects/message.rb', line 86 def forward_sender_name @message.forward_sender_name end |
#forward_signature ⇒ Object
Optional.
For messages forwarded from channels, signature of the post author if present.
80 81 82 |
# File 'lib/objects/message.rb', line 80 def forward_signature @message.forward_signature end |
#from ⇒ Object
Optional.
Sender, empty for messages sent to channels. Returns User object.
35 36 37 38 39 40 |
# File 'lib/objects/message.rb', line 35 def from frm = @message.from return User.new(frm) if frm false end |
#game ⇒ Object
Optional
. Message is a Game, information about the game.
269 270 271 272 273 274 |
# File 'lib/objects/message.rb', line 269 def game gam = @message.game return Game.new(gam) if gam false end |
#game_msg? ⇒ Boolean
325 326 327 |
# File 'lib/objects/message.rb', line 325 def game_msg? @message.game ? true : false end |
#has_entities? ⇒ Boolean
373 374 375 |
# File 'lib/objects/message.rb', line 373 def has_entities? @message.entities.empty? ? false : true end |
#left_chat_member? ⇒ Boolean
345 346 347 |
# File 'lib/objects/message.rb', line 345 def left_chat_member? @message.left_chat_member ? true : false end |
#location_msg? ⇒ Boolean
337 338 339 |
# File 'lib/objects/message.rb', line 337 def location_msg? @message.location ? true : false end |
#media_group_id ⇒ Object
Optional
. The unique identifier of a media message group this message belongs to.
124 125 126 |
# File 'lib/objects/message.rb', line 124 def media_group_id @message.media_group_id end |
#message_id ⇒ Object
Unique message identifier inside the chat.
29 30 31 |
# File 'lib/objects/message.rb', line 29 def @message. end |
#new_chat_member? ⇒ Boolean
341 342 343 |
# File 'lib/objects/message.rb', line 341 def new_chat_member? @message.new_chat_member ? true : false end |
#new_chat_photo? ⇒ Boolean
353 354 355 |
# File 'lib/objects/message.rb', line 353 def new_chat_photo? @message.new_chat_photo ? true : false end |
#new_chat_title? ⇒ Boolean
349 350 351 |
# File 'lib/objects/message.rb', line 349 def new_chat_title? @message.new_chat_title ? true : false end |
#photo ⇒ Object
Optional
. message is a Photo, available sizes of the photo. returns array of PhotoSize object
185 186 187 188 189 190 191 192 193 194 195 196 |
# 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? ⇒ Boolean
309 310 311 |
# File 'lib/objects/message.rb', line 309 def photo_msg? @message.photo.empty? ? false : true end |
#pinned_msg? ⇒ Boolean
357 358 359 |
# File 'lib/objects/message.rb', line 357 def pinned_msg? @message. ? true : false end |
#poll_msg? ⇒ Boolean
329 330 331 |
# File 'lib/objects/message.rb', line 329 def poll_msg? @message.poll ? true : false end |
#reply_markup? ⇒ Boolean
365 366 367 |
# File 'lib/objects/message.rb', line 365 def reply_markup? @message.reply_markup ? true : false end |
#reply_msg? ⇒ Boolean
returns true if the update is for replied msg
281 282 283 |
# File 'lib/objects/message.rb', line 281 def reply_msg? @message. ? true : false end |
#reply_to_message ⇒ Object
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
101 102 103 104 105 106 |
# File 'lib/objects/message.rb', line 101 def r_t_msg = @message. return Message.new(r_t_msg) if r_t_msg false end |
#sticker ⇒ Object
Optional.
Message is a sticker, information about the sticker returns Sticker object
200 201 202 203 204 205 |
# File 'lib/objects/message.rb', line 200 def sticker stiker = @message.sticker return Sticker.new(stiker) if stiker false end |
#sticker_msg? ⇒ Boolean
321 322 323 |
# File 'lib/objects/message.rb', line 321 def sticker_msg? @message.sticker ? true : false end |
#text ⇒ Object
Optional
. For text messages, the actual UTF-8 text of the message, 0-4096 characters
135 136 137 |
# File 'lib/objects/message.rb', line 135 def text @message.text end |
#text_msg? ⇒ Boolean
276 277 278 |
# File 'lib/objects/message.rb', line 276 def text_msg? text ? true : false end |
#venue_msg? ⇒ Boolean
333 334 335 |
# File 'lib/objects/message.rb', line 333 def venue_msg? @message.venue ? true : false end |
#via_bot ⇒ Object
Optional
. Bot through which the message was sent. Returns User object.
110 111 112 113 114 115 |
# 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 ⇒ Object
Optional.
Message is a Video, information about the video.
208 209 210 211 212 213 |
# File 'lib/objects/message.rb', line 208 def video vd = @message.video return Video.new(vd) if vd false end |
#video_msg? ⇒ Boolean
285 286 287 |
# File 'lib/objects/message.rb', line 285 def video_msg? @message.video ? true : false end |
#video_note ⇒ Object
Optional.
Message is a VideoNote, information about the video message.
216 217 218 219 220 221 |
# 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? ⇒ Boolean
317 318 319 |
# File 'lib/objects/message.rb', line 317 def video_note_msg? @message.video_note ? true : false end |
#voice ⇒ Object
Optional
. message is a Voice message, information about the file.
224 225 226 227 228 229 |
# File 'lib/objects/message.rb', line 224 def voice vc = @message.voice return Voice.new(vc) if vc false end |
#voice_msg? ⇒ Boolean
313 314 315 |
# File 'lib/objects/message.rb', line 313 def voice_msg? @message.voice ? true : false end |