Class: TelegramBot::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/telegram-bot/models/message.rb

Overview

This object represents a message.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Message

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
# File 'lib/telegram-bot/models/message.rb', line 444

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `TelegramBot::Message` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `TelegramBot::Message`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'message_id')
    self.message_id = attributes[:'message_id']
  else
    self.message_id = nil
  end

  if attributes.key?(:'message_thread_id')
    self.message_thread_id = attributes[:'message_thread_id']
  end

  if attributes.key?(:'from')
    self.from = attributes[:'from']
  end

  if attributes.key?(:'sender_chat')
    self.sender_chat = attributes[:'sender_chat']
  end

  if attributes.key?(:'sender_boost_count')
    self.sender_boost_count = attributes[:'sender_boost_count']
  end

  if attributes.key?(:'sender_business_bot')
    self.sender_business_bot = attributes[:'sender_business_bot']
  end

  if attributes.key?(:'date')
    self.date = attributes[:'date']
  else
    self.date = nil
  end

  if attributes.key?(:'business_connection_id')
    self.business_connection_id = attributes[:'business_connection_id']
  end

  if attributes.key?(:'chat')
    self.chat = attributes[:'chat']
  else
    self.chat = nil
  end

  if attributes.key?(:'forward_origin')
    self.forward_origin = attributes[:'forward_origin']
  end

  if attributes.key?(:'is_topic_message')
    self.is_topic_message = attributes[:'is_topic_message']
  end

  if attributes.key?(:'is_automatic_forward')
    self.is_automatic_forward = attributes[:'is_automatic_forward']
  end

  if attributes.key?(:'reply_to_message')
    self.reply_to_message = attributes[:'reply_to_message']
  end

  if attributes.key?(:'external_reply')
    self.external_reply = attributes[:'external_reply']
  end

  if attributes.key?(:'quote')
    self.quote = attributes[:'quote']
  end

  if attributes.key?(:'reply_to_story')
    self.reply_to_story = attributes[:'reply_to_story']
  end

  if attributes.key?(:'via_bot')
    self.via_bot = attributes[:'via_bot']
  end

  if attributes.key?(:'edit_date')
    self.edit_date = attributes[:'edit_date']
  end

  if attributes.key?(:'has_protected_content')
    self.has_protected_content = attributes[:'has_protected_content']
  end

  if attributes.key?(:'is_from_offline')
    self.is_from_offline = attributes[:'is_from_offline']
  end

  if attributes.key?(:'media_group_id')
    self.media_group_id = attributes[:'media_group_id']
  end

  if attributes.key?(:'author_signature')
    self.author_signature = attributes[:'author_signature']
  end

  if attributes.key?(:'text')
    self.text = attributes[:'text']
  end

  if attributes.key?(:'entities')
    if (value = attributes[:'entities']).is_a?(Array)
      self.entities = value
    end
  end

  if attributes.key?(:'link_preview_options')
    self.link_preview_options = attributes[:'link_preview_options']
  end

  if attributes.key?(:'animation')
    self.animation = attributes[:'animation']
  end

  if attributes.key?(:'audio')
    self.audio = attributes[:'audio']
  end

  if attributes.key?(:'document')
    self.document = attributes[:'document']
  end

  if attributes.key?(:'photo')
    if (value = attributes[:'photo']).is_a?(Array)
      self.photo = value
    end
  end

  if attributes.key?(:'sticker')
    self.sticker = attributes[:'sticker']
  end

  if attributes.key?(:'story')
    self.story = attributes[:'story']
  end

  if attributes.key?(:'video')
    self.video = attributes[:'video']
  end

  if attributes.key?(:'video_note')
    self.video_note = attributes[:'video_note']
  end

  if attributes.key?(:'voice')
    self.voice = attributes[:'voice']
  end

  if attributes.key?(:'caption')
    self.caption = attributes[:'caption']
  end

  if attributes.key?(:'caption_entities')
    if (value = attributes[:'caption_entities']).is_a?(Array)
      self.caption_entities = value
    end
  end

  if attributes.key?(:'has_media_spoiler')
    self.has_media_spoiler = attributes[:'has_media_spoiler']
  end

  if attributes.key?(:'contact')
    self.contact = attributes[:'contact']
  end

  if attributes.key?(:'dice')
    self.dice = attributes[:'dice']
  end

  if attributes.key?(:'game')
    self.game = attributes[:'game']
  end

  if attributes.key?(:'poll')
    self.poll = attributes[:'poll']
  end

  if attributes.key?(:'venue')
    self.venue = attributes[:'venue']
  end

  if attributes.key?(:'location')
    self.location = attributes[:'location']
  end

  if attributes.key?(:'new_chat_members')
    if (value = attributes[:'new_chat_members']).is_a?(Array)
      self.new_chat_members = value
    end
  end

  if attributes.key?(:'left_chat_member')
    self.left_chat_member = attributes[:'left_chat_member']
  end

  if attributes.key?(:'new_chat_title')
    self.new_chat_title = attributes[:'new_chat_title']
  end

  if attributes.key?(:'new_chat_photo')
    if (value = attributes[:'new_chat_photo']).is_a?(Array)
      self.new_chat_photo = value
    end
  end

  if attributes.key?(:'delete_chat_photo')
    self.delete_chat_photo = attributes[:'delete_chat_photo']
  end

  if attributes.key?(:'group_chat_created')
    self.group_chat_created = attributes[:'group_chat_created']
  end

  if attributes.key?(:'supergroup_chat_created')
    self.supergroup_chat_created = attributes[:'supergroup_chat_created']
  end

  if attributes.key?(:'channel_chat_created')
    self.channel_chat_created = attributes[:'channel_chat_created']
  end

  if attributes.key?(:'message_auto_delete_timer_changed')
    self.message_auto_delete_timer_changed = attributes[:'message_auto_delete_timer_changed']
  end

  if attributes.key?(:'migrate_to_chat_id')
    self.migrate_to_chat_id = attributes[:'migrate_to_chat_id']
  end

  if attributes.key?(:'migrate_from_chat_id')
    self.migrate_from_chat_id = attributes[:'migrate_from_chat_id']
  end

  if attributes.key?(:'pinned_message')
    self.pinned_message = attributes[:'pinned_message']
  end

  if attributes.key?(:'invoice')
    self.invoice = attributes[:'invoice']
  end

  if attributes.key?(:'successful_payment')
    self.successful_payment = attributes[:'successful_payment']
  end

  if attributes.key?(:'users_shared')
    self.users_shared = attributes[:'users_shared']
  end

  if attributes.key?(:'chat_shared')
    self.chat_shared = attributes[:'chat_shared']
  end

  if attributes.key?(:'connected_website')
    self.connected_website = attributes[:'connected_website']
  end

  if attributes.key?(:'write_access_allowed')
    self.write_access_allowed = attributes[:'write_access_allowed']
  end

  if attributes.key?(:'passport_data')
    self.passport_data = attributes[:'passport_data']
  end

  if attributes.key?(:'proximity_alert_triggered')
    self.proximity_alert_triggered = attributes[:'proximity_alert_triggered']
  end

  if attributes.key?(:'boost_added')
    self.boost_added = attributes[:'boost_added']
  end

  if attributes.key?(:'forum_topic_created')
    self.forum_topic_created = attributes[:'forum_topic_created']
  end

  if attributes.key?(:'forum_topic_edited')
    self.forum_topic_edited = attributes[:'forum_topic_edited']
  end

  if attributes.key?(:'forum_topic_closed')
    self.forum_topic_closed = attributes[:'forum_topic_closed']
  end

  if attributes.key?(:'forum_topic_reopened')
    self.forum_topic_reopened = attributes[:'forum_topic_reopened']
  end

  if attributes.key?(:'general_forum_topic_hidden')
    self.general_forum_topic_hidden = attributes[:'general_forum_topic_hidden']
  end

  if attributes.key?(:'general_forum_topic_unhidden')
    self.general_forum_topic_unhidden = attributes[:'general_forum_topic_unhidden']
  end

  if attributes.key?(:'giveaway_created')
    self.giveaway_created = attributes[:'giveaway_created']
  end

  if attributes.key?(:'giveaway')
    self.giveaway = attributes[:'giveaway']
  end

  if attributes.key?(:'giveaway_winners')
    self.giveaway_winners = attributes[:'giveaway_winners']
  end

  if attributes.key?(:'giveaway_completed')
    self.giveaway_completed = attributes[:'giveaway_completed']
  end

  if attributes.key?(:'video_chat_scheduled')
    self.video_chat_scheduled = attributes[:'video_chat_scheduled']
  end

  if attributes.key?(:'video_chat_started')
    self.video_chat_started = attributes[:'video_chat_started']
  end

  if attributes.key?(:'video_chat_ended')
    self.video_chat_ended = attributes[:'video_chat_ended']
  end

  if attributes.key?(:'video_chat_participants_invited')
    self.video_chat_participants_invited = attributes[:'video_chat_participants_invited']
  end

  if attributes.key?(:'web_app_data')
    self.web_app_data = attributes[:'web_app_data']
  end

  if attributes.key?(:'reply_markup')
    self.reply_markup = attributes[:'reply_markup']
  end
end

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



95
96
97
# File 'lib/telegram-bot/models/message.rb', line 95

def animation
  @animation
end

#audioObject

Optional. Message is an audio file, information about the file



98
99
100
# File 'lib/telegram-bot/models/message.rb', line 98

def audio
  @audio
end

#author_signatureObject

Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group administrator



83
84
85
# File 'lib/telegram-bot/models/message.rb', line 83

def author_signature
  @author_signature
end

#boost_addedObject

Optional. Service message: user boosted the chat



209
210
211
# File 'lib/telegram-bot/models/message.rb', line 209

def boost_added
  @boost_added
end

#business_connection_idObject

Optional. Unique identifier of the business connection from which the message was received. If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier.



41
42
43
# File 'lib/telegram-bot/models/message.rb', line 41

def business_connection_id
  @business_connection_id
end

#captionObject

Optional. Caption for the animation, audio, document, photo, video or voice



122
123
124
# File 'lib/telegram-bot/models/message.rb', line 122

def caption
  @caption
end

#caption_entitiesObject

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



125
126
127
# File 'lib/telegram-bot/models/message.rb', line 125

def caption_entities
  @caption_entities
end

#channel_chat_createdObject

Optional. Service message: the channel has been created. This field can’t be received in a message coming through updates, because bot can’t be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel.



170
171
172
# File 'lib/telegram-bot/models/message.rb', line 170

def channel_chat_created
  @channel_chat_created
end

#chatObject

Chat the message belongs to



44
45
46
# File 'lib/telegram-bot/models/message.rb', line 44

def chat
  @chat
end

#chat_sharedObject

Optional. Service message: a chat was shared with the bot



194
195
196
# File 'lib/telegram-bot/models/message.rb', line 194

def chat_shared
  @chat_shared
end

#connected_websiteObject

Optional. The domain name of the website on which the user has logged in. More about Telegram Login: core.telegram.org/widgets/login



197
198
199
# File 'lib/telegram-bot/models/message.rb', line 197

def connected_website
  @connected_website
end

#contactObject

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



131
132
133
# File 'lib/telegram-bot/models/message.rb', line 131

def contact
  @contact
end

#dateObject

Date the message was sent in Unix time. It is always a positive number, representing a valid date.



38
39
40
# File 'lib/telegram-bot/models/message.rb', line 38

def date
  @date
end

#delete_chat_photoObject

Optional. Service message: the chat photo was deleted



161
162
163
# File 'lib/telegram-bot/models/message.rb', line 161

def delete_chat_photo
  @delete_chat_photo
end

#diceObject

Optional. Message is a dice with random value



134
135
136
# File 'lib/telegram-bot/models/message.rb', line 134

def dice
  @dice
end

#documentObject

Optional. Message is a general file, information about the file



101
102
103
# File 'lib/telegram-bot/models/message.rb', line 101

def document
  @document
end

#edit_dateObject

Optional. Date the message was last edited in Unix time



71
72
73
# File 'lib/telegram-bot/models/message.rb', line 71

def edit_date
  @edit_date
end

#entitiesObject

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



89
90
91
# File 'lib/telegram-bot/models/message.rb', line 89

def entities
  @entities
end

#external_replyObject

Optional. Information about the message that is being replied to, which may come from another chat or forum topic



59
60
61
# File 'lib/telegram-bot/models/message.rb', line 59

def external_reply
  @external_reply
end

#forum_topic_closedObject

Optional. Service message: forum topic closed



218
219
220
# File 'lib/telegram-bot/models/message.rb', line 218

def forum_topic_closed
  @forum_topic_closed
end

#forum_topic_createdObject

Optional. Service message: forum topic created



212
213
214
# File 'lib/telegram-bot/models/message.rb', line 212

def forum_topic_created
  @forum_topic_created
end

#forum_topic_editedObject

Optional. Service message: forum topic edited



215
216
217
# File 'lib/telegram-bot/models/message.rb', line 215

def forum_topic_edited
  @forum_topic_edited
end

#forum_topic_reopenedObject

Optional. Service message: forum topic reopened



221
222
223
# File 'lib/telegram-bot/models/message.rb', line 221

def forum_topic_reopened
  @forum_topic_reopened
end

#forward_originObject

Optional. Information about the original message for forwarded messages



47
48
49
# File 'lib/telegram-bot/models/message.rb', line 47

def forward_origin
  @forward_origin
end

#fromObject

Optional. Sender of the message; empty for messages sent to channels. For backward compatibility, the field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.



26
27
28
# File 'lib/telegram-bot/models/message.rb', line 26

def from
  @from
end

#gameObject

Optional. Message is a game, information about the game. More about games: core.telegram.org/bots/api#games



137
138
139
# File 'lib/telegram-bot/models/message.rb', line 137

def game
  @game
end

#general_forum_topic_hiddenObject

Optional. Service message: the ‘General’ forum topic hidden



224
225
226
# File 'lib/telegram-bot/models/message.rb', line 224

def general_forum_topic_hidden
  @general_forum_topic_hidden
end

#general_forum_topic_unhiddenObject

Optional. Service message: the ‘General’ forum topic unhidden



227
228
229
# File 'lib/telegram-bot/models/message.rb', line 227

def general_forum_topic_unhidden
  @general_forum_topic_unhidden
end

#giveawayObject

Optional. The message is a scheduled giveaway message



233
234
235
# File 'lib/telegram-bot/models/message.rb', line 233

def giveaway
  @giveaway
end

#giveaway_completedObject

Optional. Service message: a giveaway without public winners was completed



239
240
241
# File 'lib/telegram-bot/models/message.rb', line 239

def giveaway_completed
  @giveaway_completed
end

#giveaway_createdObject

Optional. Service message: a scheduled giveaway was created



230
231
232
# File 'lib/telegram-bot/models/message.rb', line 230

def giveaway_created
  @giveaway_created
end

#giveaway_winnersObject

Optional. A giveaway with public winners was completed



236
237
238
# File 'lib/telegram-bot/models/message.rb', line 236

def giveaway_winners
  @giveaway_winners
end

#group_chat_createdObject

Optional. Service message: the group has been created



164
165
166
# File 'lib/telegram-bot/models/message.rb', line 164

def group_chat_created
  @group_chat_created
end

#has_media_spoilerObject

Optional. True, if the message media is covered by a spoiler animation



128
129
130
# File 'lib/telegram-bot/models/message.rb', line 128

def has_media_spoiler
  @has_media_spoiler
end

#has_protected_contentObject

Optional. True, if the message can’t be forwarded



74
75
76
# File 'lib/telegram-bot/models/message.rb', line 74

def has_protected_content
  @has_protected_content
end

#invoiceObject

Optional. Message is an invoice for a payment, information about the invoice. More about payments: core.telegram.org/bots/api#payments



185
186
187
# File 'lib/telegram-bot/models/message.rb', line 185

def invoice
  @invoice
end

#is_automatic_forwardObject

Optional. True, if the message is a channel post that was automatically forwarded to the connected discussion group



53
54
55
# File 'lib/telegram-bot/models/message.rb', line 53

def is_automatic_forward
  @is_automatic_forward
end

#is_from_offlineObject

Optional. True, if the message was sent by an implicit action, for example, as an away or a greeting business message, or as a scheduled message



77
78
79
# File 'lib/telegram-bot/models/message.rb', line 77

def is_from_offline
  @is_from_offline
end

#is_topic_messageObject

Optional. True, if the message is sent to a forum topic



50
51
52
# File 'lib/telegram-bot/models/message.rb', line 50

def is_topic_message
  @is_topic_message
end

#left_chat_memberObject

Optional. A member was removed from the group, information about them (this member may be the bot itself)



152
153
154
# File 'lib/telegram-bot/models/message.rb', line 152

def left_chat_member
  @left_chat_member
end

Optional. Options used for link preview generation for the message, if it is a text message and link preview options were changed



92
93
94
# File 'lib/telegram-bot/models/message.rb', line 92

def link_preview_options
  @link_preview_options
end

#locationObject

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



146
147
148
# File 'lib/telegram-bot/models/message.rb', line 146

def location
  @location
end

#media_group_idObject

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



80
81
82
# File 'lib/telegram-bot/models/message.rb', line 80

def media_group_id
  @media_group_id
end

#message_auto_delete_timer_changedObject

Optional. Service message: auto-delete timer settings changed in the chat



173
174
175
# File 'lib/telegram-bot/models/message.rb', line 173

def message_auto_delete_timer_changed
  @message_auto_delete_timer_changed
end

#message_idObject

Unique message identifier inside this chat



20
21
22
# File 'lib/telegram-bot/models/message.rb', line 20

def message_id
  @message_id
end

#message_thread_idObject

Optional. Unique identifier of a message thread to which the message belongs; for supergroups only



23
24
25
# File 'lib/telegram-bot/models/message.rb', line 23

def message_thread_id
  @message_thread_id
end

#migrate_from_chat_idObject

Optional. The supergroup has been migrated from a group with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.



179
180
181
# File 'lib/telegram-bot/models/message.rb', line 179

def migrate_from_chat_id
  @migrate_from_chat_id
end

#migrate_to_chat_idObject

Optional. The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.



176
177
178
# File 'lib/telegram-bot/models/message.rb', line 176

def migrate_to_chat_id
  @migrate_to_chat_id
end

#new_chat_membersObject

Optional. New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)



149
150
151
# File 'lib/telegram-bot/models/message.rb', line 149

def new_chat_members
  @new_chat_members
end

#new_chat_photoObject

Optional. A chat photo was change to this value



158
159
160
# File 'lib/telegram-bot/models/message.rb', line 158

def new_chat_photo
  @new_chat_photo
end

#new_chat_titleObject

Optional. A chat title was changed to this value



155
156
157
# File 'lib/telegram-bot/models/message.rb', line 155

def new_chat_title
  @new_chat_title
end

#passport_dataObject

Optional. Telegram Passport data



203
204
205
# File 'lib/telegram-bot/models/message.rb', line 203

def passport_data
  @passport_data
end

#photoObject

Optional. Message is a photo, available sizes of the photo



104
105
106
# File 'lib/telegram-bot/models/message.rb', line 104

def photo
  @photo
end

#pinned_messageObject

Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.



182
183
184
# File 'lib/telegram-bot/models/message.rb', line 182

def pinned_message
  @pinned_message
end

#pollObject

Optional. Message is a native poll, information about the poll



140
141
142
# File 'lib/telegram-bot/models/message.rb', line 140

def poll
  @poll
end

#proximity_alert_triggeredObject

Optional. Service message. A user in the chat triggered another user’s proximity alert while sharing Live Location.



206
207
208
# File 'lib/telegram-bot/models/message.rb', line 206

def proximity_alert_triggered
  @proximity_alert_triggered
end

#quoteObject

Optional. For replies that quote part of the original message, the quoted part of the message



62
63
64
# File 'lib/telegram-bot/models/message.rb', line 62

def quote
  @quote
end

#reply_markupObject

Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons.



257
258
259
# File 'lib/telegram-bot/models/message.rb', line 257

def reply_markup
  @reply_markup
end

#reply_to_messageObject

Optional. For replies in the same chat and message thread, 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.



56
57
58
# File 'lib/telegram-bot/models/message.rb', line 56

def reply_to_message
  @reply_to_message
end

#reply_to_storyObject

Optional. For replies to a story, the original story



65
66
67
# File 'lib/telegram-bot/models/message.rb', line 65

def reply_to_story
  @reply_to_story
end

#sender_boost_countObject

Optional. If the sender of the message boosted the chat, the number of boosts added by the user



32
33
34
# File 'lib/telegram-bot/models/message.rb', line 32

def sender_boost_count
  @sender_boost_count
end

#sender_business_botObject

Optional. The bot that actually sent the message on behalf of the business account. Available only for outgoing messages sent on behalf of the connected business account.



35
36
37
# File 'lib/telegram-bot/models/message.rb', line 35

def sender_business_bot
  @sender_business_bot
end

#sender_chatObject

Optional. Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. For backward compatibility, the field from contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.



29
30
31
# File 'lib/telegram-bot/models/message.rb', line 29

def sender_chat
  @sender_chat
end

#stickerObject

Optional. Message is a sticker, information about the sticker



107
108
109
# File 'lib/telegram-bot/models/message.rb', line 107

def sticker
  @sticker
end

#storyObject

Optional. Message is a forwarded story



110
111
112
# File 'lib/telegram-bot/models/message.rb', line 110

def story
  @story
end

#successful_paymentObject

Optional. Message is a service message about a successful payment, information about the payment. More about payments: core.telegram.org/bots/api#payments



188
189
190
# File 'lib/telegram-bot/models/message.rb', line 188

def successful_payment
  @successful_payment
end

#supergroup_chat_createdObject

Optional. Service message: the supergroup has been created. This field can’t be received in a message coming through updates, because bot can’t be a member of a supergroup when it is created. It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup.



167
168
169
# File 'lib/telegram-bot/models/message.rb', line 167

def supergroup_chat_created
  @supergroup_chat_created
end

#textObject

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



86
87
88
# File 'lib/telegram-bot/models/message.rb', line 86

def text
  @text
end

#users_sharedObject

Optional. Service message: users were shared with the bot



191
192
193
# File 'lib/telegram-bot/models/message.rb', line 191

def users_shared
  @users_shared
end

#venueObject

Optional. Message is a venue, information about the venue. For backward compatibility, when this field is set, the location field will also be set



143
144
145
# File 'lib/telegram-bot/models/message.rb', line 143

def venue
  @venue
end

#via_botObject

Optional. Bot through which the message was sent



68
69
70
# File 'lib/telegram-bot/models/message.rb', line 68

def via_bot
  @via_bot
end

#videoObject

Optional. Message is a video, information about the video



113
114
115
# File 'lib/telegram-bot/models/message.rb', line 113

def video
  @video
end

#video_chat_endedObject

Optional. Service message: video chat ended



248
249
250
# File 'lib/telegram-bot/models/message.rb', line 248

def video_chat_ended
  @video_chat_ended
end

#video_chat_participants_invitedObject

Optional. Service message: new participants invited to a video chat



251
252
253
# File 'lib/telegram-bot/models/message.rb', line 251

def video_chat_participants_invited
  @video_chat_participants_invited
end

#video_chat_scheduledObject

Optional. Service message: video chat scheduled



242
243
244
# File 'lib/telegram-bot/models/message.rb', line 242

def video_chat_scheduled
  @video_chat_scheduled
end

#video_chat_startedObject

Optional. Service message: video chat started



245
246
247
# File 'lib/telegram-bot/models/message.rb', line 245

def video_chat_started
  @video_chat_started
end

#video_noteObject

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



116
117
118
# File 'lib/telegram-bot/models/message.rb', line 116

def video_note
  @video_note
end

#voiceObject

Optional. Message is a voice message, information about the file



119
120
121
# File 'lib/telegram-bot/models/message.rb', line 119

def voice
  @voice
end

#web_app_dataObject

Optional. Service message: data sent by a Web App



254
255
256
# File 'lib/telegram-bot/models/message.rb', line 254

def web_app_data
  @web_app_data
end

#write_access_allowedObject

Optional. Service message: the user allowed the bot to write messages after adding it to the attachment or side menu, launching a Web App from a link, or accepting an explicit request from a Web App sent by the method requestWriteAccess



200
201
202
# File 'lib/telegram-bot/models/message.rb', line 200

def write_access_allowed
  @write_access_allowed
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
# File 'lib/telegram-bot/models/message.rb', line 950

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = TelegramBot.const_get(type)
    klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



346
347
348
# File 'lib/telegram-bot/models/message.rb', line 346

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/telegram-bot/models/message.rb', line 260

def self.attribute_map
  {
    :'message_id' => :'message_id',
    :'message_thread_id' => :'message_thread_id',
    :'from' => :'from',
    :'sender_chat' => :'sender_chat',
    :'sender_boost_count' => :'sender_boost_count',
    :'sender_business_bot' => :'sender_business_bot',
    :'date' => :'date',
    :'business_connection_id' => :'business_connection_id',
    :'chat' => :'chat',
    :'forward_origin' => :'forward_origin',
    :'is_topic_message' => :'is_topic_message',
    :'is_automatic_forward' => :'is_automatic_forward',
    :'reply_to_message' => :'reply_to_message',
    :'external_reply' => :'external_reply',
    :'quote' => :'quote',
    :'reply_to_story' => :'reply_to_story',
    :'via_bot' => :'via_bot',
    :'edit_date' => :'edit_date',
    :'has_protected_content' => :'has_protected_content',
    :'is_from_offline' => :'is_from_offline',
    :'media_group_id' => :'media_group_id',
    :'author_signature' => :'author_signature',
    :'text' => :'text',
    :'entities' => :'entities',
    :'link_preview_options' => :'link_preview_options',
    :'animation' => :'animation',
    :'audio' => :'audio',
    :'document' => :'document',
    :'photo' => :'photo',
    :'sticker' => :'sticker',
    :'story' => :'story',
    :'video' => :'video',
    :'video_note' => :'video_note',
    :'voice' => :'voice',
    :'caption' => :'caption',
    :'caption_entities' => :'caption_entities',
    :'has_media_spoiler' => :'has_media_spoiler',
    :'contact' => :'contact',
    :'dice' => :'dice',
    :'game' => :'game',
    :'poll' => :'poll',
    :'venue' => :'venue',
    :'location' => :'location',
    :'new_chat_members' => :'new_chat_members',
    :'left_chat_member' => :'left_chat_member',
    :'new_chat_title' => :'new_chat_title',
    :'new_chat_photo' => :'new_chat_photo',
    :'delete_chat_photo' => :'delete_chat_photo',
    :'group_chat_created' => :'group_chat_created',
    :'supergroup_chat_created' => :'supergroup_chat_created',
    :'channel_chat_created' => :'channel_chat_created',
    :'message_auto_delete_timer_changed' => :'message_auto_delete_timer_changed',
    :'migrate_to_chat_id' => :'migrate_to_chat_id',
    :'migrate_from_chat_id' => :'migrate_from_chat_id',
    :'pinned_message' => :'pinned_message',
    :'invoice' => :'invoice',
    :'successful_payment' => :'successful_payment',
    :'users_shared' => :'users_shared',
    :'chat_shared' => :'chat_shared',
    :'connected_website' => :'connected_website',
    :'write_access_allowed' => :'write_access_allowed',
    :'passport_data' => :'passport_data',
    :'proximity_alert_triggered' => :'proximity_alert_triggered',
    :'boost_added' => :'boost_added',
    :'forum_topic_created' => :'forum_topic_created',
    :'forum_topic_edited' => :'forum_topic_edited',
    :'forum_topic_closed' => :'forum_topic_closed',
    :'forum_topic_reopened' => :'forum_topic_reopened',
    :'general_forum_topic_hidden' => :'general_forum_topic_hidden',
    :'general_forum_topic_unhidden' => :'general_forum_topic_unhidden',
    :'giveaway_created' => :'giveaway_created',
    :'giveaway' => :'giveaway',
    :'giveaway_winners' => :'giveaway_winners',
    :'giveaway_completed' => :'giveaway_completed',
    :'video_chat_scheduled' => :'video_chat_scheduled',
    :'video_chat_started' => :'video_chat_started',
    :'video_chat_ended' => :'video_chat_ended',
    :'video_chat_participants_invited' => :'video_chat_participants_invited',
    :'web_app_data' => :'web_app_data',
    :'reply_markup' => :'reply_markup'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
# File 'lib/telegram-bot/models/message.rb', line 926

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



437
438
439
440
# File 'lib/telegram-bot/models/message.rb', line 437

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/telegram-bot/models/message.rb', line 351

def self.openapi_types
  {
    :'message_id' => :'Integer',
    :'message_thread_id' => :'Integer',
    :'from' => :'User',
    :'sender_chat' => :'Chat',
    :'sender_boost_count' => :'Integer',
    :'sender_business_bot' => :'User',
    :'date' => :'Integer',
    :'business_connection_id' => :'String',
    :'chat' => :'Chat',
    :'forward_origin' => :'Object',
    :'is_topic_message' => :'Boolean',
    :'is_automatic_forward' => :'Boolean',
    :'reply_to_message' => :'Message',
    :'external_reply' => :'ExternalReplyInfo',
    :'quote' => :'TextQuote',
    :'reply_to_story' => :'Story',
    :'via_bot' => :'User',
    :'edit_date' => :'Integer',
    :'has_protected_content' => :'Boolean',
    :'is_from_offline' => :'Boolean',
    :'media_group_id' => :'String',
    :'author_signature' => :'String',
    :'text' => :'String',
    :'entities' => :'Array<MessageEntity>',
    :'link_preview_options' => :'LinkPreviewOptions',
    :'animation' => :'Animation',
    :'audio' => :'Audio',
    :'document' => :'Document',
    :'photo' => :'Array<PhotoSize>',
    :'sticker' => :'Sticker',
    :'story' => :'Story',
    :'video' => :'Video',
    :'video_note' => :'VideoNote',
    :'voice' => :'Voice',
    :'caption' => :'String',
    :'caption_entities' => :'Array<MessageEntity>',
    :'has_media_spoiler' => :'Boolean',
    :'contact' => :'Contact',
    :'dice' => :'Dice',
    :'game' => :'Game',
    :'poll' => :'Poll',
    :'venue' => :'Venue',
    :'location' => :'Location',
    :'new_chat_members' => :'Array<User>',
    :'left_chat_member' => :'User',
    :'new_chat_title' => :'String',
    :'new_chat_photo' => :'Array<PhotoSize>',
    :'delete_chat_photo' => :'Boolean',
    :'group_chat_created' => :'Boolean',
    :'supergroup_chat_created' => :'Boolean',
    :'channel_chat_created' => :'Boolean',
    :'message_auto_delete_timer_changed' => :'MessageAutoDeleteTimerChanged',
    :'migrate_to_chat_id' => :'Integer',
    :'migrate_from_chat_id' => :'Integer',
    :'pinned_message' => :'Object',
    :'invoice' => :'Invoice',
    :'successful_payment' => :'SuccessfulPayment',
    :'users_shared' => :'UsersShared',
    :'chat_shared' => :'ChatShared',
    :'connected_website' => :'String',
    :'write_access_allowed' => :'WriteAccessAllowed',
    :'passport_data' => :'PassportData',
    :'proximity_alert_triggered' => :'ProximityAlertTriggered',
    :'boost_added' => :'ChatBoostAdded',
    :'forum_topic_created' => :'ForumTopicCreated',
    :'forum_topic_edited' => :'ForumTopicEdited',
    :'forum_topic_closed' => :'Object',
    :'forum_topic_reopened' => :'Object',
    :'general_forum_topic_hidden' => :'Object',
    :'general_forum_topic_unhidden' => :'Object',
    :'giveaway_created' => :'Object',
    :'giveaway' => :'Giveaway',
    :'giveaway_winners' => :'GiveawayWinners',
    :'giveaway_completed' => :'GiveawayCompleted',
    :'video_chat_scheduled' => :'VideoChatScheduled',
    :'video_chat_started' => :'Object',
    :'video_chat_ended' => :'VideoChatEnded',
    :'video_chat_participants_invited' => :'VideoChatParticipantsInvited',
    :'web_app_data' => :'WebAppData',
    :'reply_markup' => :'InlineKeyboardMarkup'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
# File 'lib/telegram-bot/models/message.rb', line 826

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      message_id == o.message_id &&
      message_thread_id == o.message_thread_id &&
      from == o.from &&
      sender_chat == o.sender_chat &&
      sender_boost_count == o.sender_boost_count &&
      sender_business_bot == o.sender_business_bot &&
      date == o.date &&
      business_connection_id == o.business_connection_id &&
      chat == o.chat &&
      forward_origin == o.forward_origin &&
      is_topic_message == o.is_topic_message &&
      is_automatic_forward == o.is_automatic_forward &&
      reply_to_message == o.reply_to_message &&
      external_reply == o.external_reply &&
      quote == o.quote &&
      reply_to_story == o.reply_to_story &&
      via_bot == o.via_bot &&
      edit_date == o.edit_date &&
      has_protected_content == o.has_protected_content &&
      is_from_offline == o.is_from_offline &&
      media_group_id == o.media_group_id &&
      author_signature == o.author_signature &&
      text == o.text &&
      entities == o.entities &&
      link_preview_options == o.link_preview_options &&
      animation == o.animation &&
      audio == o.audio &&
      document == o.document &&
      photo == o.photo &&
      sticker == o.sticker &&
      story == o.story &&
      video == o.video &&
      video_note == o.video_note &&
      voice == o.voice &&
      caption == o.caption &&
      caption_entities == o.caption_entities &&
      has_media_spoiler == o.has_media_spoiler &&
      contact == o.contact &&
      dice == o.dice &&
      game == o.game &&
      poll == o.poll &&
      venue == o.venue &&
      location == o.location &&
      new_chat_members == o.new_chat_members &&
      left_chat_member == o.left_chat_member &&
      new_chat_title == o.new_chat_title &&
      new_chat_photo == o.new_chat_photo &&
      delete_chat_photo == o.delete_chat_photo &&
      group_chat_created == o.group_chat_created &&
      supergroup_chat_created == o.supergroup_chat_created &&
      channel_chat_created == o.channel_chat_created &&
      message_auto_delete_timer_changed == o.message_auto_delete_timer_changed &&
      migrate_to_chat_id == o.migrate_to_chat_id &&
      migrate_from_chat_id == o.migrate_from_chat_id &&
      pinned_message == o.pinned_message &&
      invoice == o.invoice &&
      successful_payment == o.successful_payment &&
      users_shared == o.users_shared &&
      chat_shared == o.chat_shared &&
      connected_website == o.connected_website &&
      write_access_allowed == o.write_access_allowed &&
      passport_data == o.passport_data &&
      proximity_alert_triggered == o.proximity_alert_triggered &&
      boost_added == o.boost_added &&
      forum_topic_created == o.forum_topic_created &&
      forum_topic_edited == o.forum_topic_edited &&
      forum_topic_closed == o.forum_topic_closed &&
      forum_topic_reopened == o.forum_topic_reopened &&
      general_forum_topic_hidden == o.general_forum_topic_hidden &&
      general_forum_topic_unhidden == o.general_forum_topic_unhidden &&
      giveaway_created == o.giveaway_created &&
      giveaway == o.giveaway &&
      giveaway_winners == o.giveaway_winners &&
      giveaway_completed == o.giveaway_completed &&
      video_chat_scheduled == o.video_chat_scheduled &&
      video_chat_started == o.video_chat_started &&
      video_chat_ended == o.video_chat_ended &&
      video_chat_participants_invited == o.video_chat_participants_invited &&
      web_app_data == o.web_app_data &&
      reply_markup == o.reply_markup
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
# File 'lib/telegram-bot/models/message.rb', line 1021

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


913
914
915
# File 'lib/telegram-bot/models/message.rb', line 913

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



919
920
921
# File 'lib/telegram-bot/models/message.rb', line 919

def hash
  [message_id, message_thread_id, from, sender_chat, sender_boost_count, sender_business_bot, date, business_connection_id, chat, forward_origin, is_topic_message, is_automatic_forward, reply_to_message, external_reply, quote, reply_to_story, via_bot, edit_date, has_protected_content, is_from_offline, media_group_id, author_signature, text, entities, link_preview_options, animation, audio, document, photo, sticker, story, video, video_note, voice, caption, caption_entities, has_media_spoiler, contact, dice, game, poll, venue, location, new_chat_members, left_chat_member, new_chat_title, new_chat_photo, delete_chat_photo, group_chat_created, supergroup_chat_created, channel_chat_created, message_auto_delete_timer_changed, migrate_to_chat_id, migrate_from_chat_id, pinned_message, invoice, successful_payment, users_shared, chat_shared, connected_website, write_access_allowed, passport_data, proximity_alert_triggered, boost_added, forum_topic_created, forum_topic_edited, forum_topic_closed, forum_topic_reopened, general_forum_topic_hidden, general_forum_topic_unhidden, giveaway_created, giveaway, giveaway_winners, giveaway_completed, video_chat_scheduled, video_chat_started, video_chat_ended, video_chat_participants_invited, web_app_data, reply_markup].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
# File 'lib/telegram-bot/models/message.rb', line 796

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @message_id.nil?
    invalid_properties.push('invalid value for "message_id", message_id cannot be nil.')
  end

  if @date.nil?
    invalid_properties.push('invalid value for "date", date cannot be nil.')
  end

  if @chat.nil?
    invalid_properties.push('invalid value for "chat", chat cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



997
998
999
# File 'lib/telegram-bot/models/message.rb', line 997

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
# File 'lib/telegram-bot/models/message.rb', line 1003

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



991
992
993
# File 'lib/telegram-bot/models/message.rb', line 991

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



816
817
818
819
820
821
822
# File 'lib/telegram-bot/models/message.rb', line 816

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @message_id.nil?
  return false if @date.nil?
  return false if @chat.nil?
  true
end