Class: Message

Inherits:
Object
  • Object
show all
Defined in:
lib/objects/message.rb

Overview

Monday, August 24 2020 EAT

This object represents a message.

Instance Method Summary collapse

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

#animationObject

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

Returns:

  • (Boolean)


305
306
307
# File 'lib/objects/message.rb', line 305

def animation_msg?
  @message.animation ? true : false
end

#audioObject

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

Returns:

  • (Boolean)


289
290
291
# File 'lib/objects/message.rb', line 289

def audio_msg?
  @message.audio ? true : false
end

#author_signatureObject

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



129
130
131
# File 'lib/objects/message.rb', line 129

def author_signature
  @message.author_signature
end

#captionObject

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 caption
  @message.caption
end

#caption_entitiesObject

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 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

#chatObject

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

#contactObject

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

Returns:

  • (Boolean)


297
298
299
# File 'lib/objects/message.rb', line 297

def contact_msg?
  @message.contact ? true : false
end

#dateObject

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

Returns:

  • (Boolean)


361
362
363
# File 'lib/objects/message.rb', line 361

def delete_chat_photo?
  @message.delete_chat_photo ? true : false
end

#diceObject

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

#documentObject

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

Returns:

  • (Boolean)


293
294
295
# File 'lib/objects/message.rb', line 293

def document_msg?
  @message.document ? true : false
end

#edit_dateObject

Optional. Retuns TDate object.



118
119
120
# File 'lib/objects/message.rb', line 118

def edit_date
  TDate.new(@messag.edit_date)
end

#entitiesObject

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_dateObject

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_fromObject

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_chatObject

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

Returns:

  • (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_idObject

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 forward_from_message_id
  @message.forward_from_message_id
end

#forward_msg?Boolean

Returns:

  • (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_nameObject

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_signatureObject

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

#fromObject

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

#gameObject

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

Returns:

  • (Boolean)


325
326
327
# File 'lib/objects/message.rb', line 325

def game_msg?
  @message.game ? true : false
end

#has_entities?Boolean

Returns:

  • (Boolean)


373
374
375
# File 'lib/objects/message.rb', line 373

def has_entities?
  @message.entities.empty? ? false : true
end

#left_chat_member?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


337
338
339
# File 'lib/objects/message.rb', line 337

def location_msg?
  @message.location ? true : false
end

#media_group_idObject

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_idObject

Unique message identifier inside the chat.



29
30
31
# File 'lib/objects/message.rb', line 29

def message_id
  @message.message_id
end

#new_chat_member?Boolean

Returns:

  • (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

Returns:

  • (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

Returns:

  • (Boolean)


349
350
351
# File 'lib/objects/message.rb', line 349

def new_chat_title?
  @message.new_chat_title ? true : false
end

#photoObject

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

Returns:

  • (Boolean)


309
310
311
# File 'lib/objects/message.rb', line 309

def photo_msg?
  @message.photo.empty? ? false : true
end

#pinned_msg?Boolean

Returns:

  • (Boolean)


357
358
359
# File 'lib/objects/message.rb', line 357

def pinned_msg?
  @message.pinned_message ? true : false
end

#poll_msg?Boolean

Returns:

  • (Boolean)


329
330
331
# File 'lib/objects/message.rb', line 329

def poll_msg?
  @message.poll ? true : false
end

#reply_markup?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


281
282
283
# File 'lib/objects/message.rb', line 281

def reply_msg?
  @message.reply_to_message ? true : false
end

#reply_to_messageObject

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 reply_to_message
  r_t_msg = @message.reply_to_message
  return Message.new(r_t_msg) if r_t_msg

  false
end

#stickerObject

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

Returns:

  • (Boolean)


321
322
323
# File 'lib/objects/message.rb', line 321

def sticker_msg?
  @message.sticker ? true : false
end

#textObject

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

Returns:

  • (Boolean)


276
277
278
# File 'lib/objects/message.rb', line 276

def text_msg?
  text ? true : false
end

#venue_msg?Boolean

Returns:

  • (Boolean)


333
334
335
# File 'lib/objects/message.rb', line 333

def venue_msg?
  @message.venue ? true : false
end

#via_botObject

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

#videoObject

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

Returns:

  • (Boolean)


285
286
287
# File 'lib/objects/message.rb', line 285

def video_msg?
  @message.video ? true : false
end

#video_noteObject

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

Returns:

  • (Boolean)


317
318
319
# File 'lib/objects/message.rb', line 317

def video_note_msg?
  @message.video_note ? true : false
end

#voiceObject

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

Returns:

  • (Boolean)


313
314
315
# File 'lib/objects/message.rb', line 313

def voice_msg?
  @message.voice ? true : false
end