forked from TelegramBot/Api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessage.php
More file actions
871 lines (765 loc) · 17 KB
/
Message.php
File metadata and controls
871 lines (765 loc) · 17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
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
344
345
346
347
348
349
350
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
435
436
437
438
439
440
441
442
443
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
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
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
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\InvalidArgumentException;
use TelegramBot\Api\TypeInterface;
use TelegramBot\Api\Types\Payments\Invoice;
use TelegramBot\Api\Types\Payments\SuccessfulPayment;
class Message extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['message_id', 'date', 'chat'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'message_id' => true,
'from' => User::class,
'date' => true,
'chat' => Chat::class,
'forward_from' => User::class,
'forward_date' => true,
'reply_to_message' => Message::class,
'text' => true,
'entities' => ArrayOfMessageEntity::class,
'audio' => Audio::class,
'document' => Document::class,
'photo' => ArrayOfPhotoSize::class,
'sticker' => Sticker::class,
'video' => Video::class,
'voice' => Voice::class,
'caption' => true,
'contact' => Contact::class,
'location' => Location::class,
'venue' => Venue::class,
'new_chat_member' => User::class,
'left_chat_member' => User::class,
'new_chat_title' => true,
'new_chat_photo' => ArrayOfPhotoSize::class,
'delete_chat_photo' => true,
'group_chat_created' => true,
'supergroup_chat_created' => true,
'channel_chat_created' => true,
'migrate_to_chat_id' => true,
'migrate_from_chat_id' => true,
'pinned_message' => Message::class,
'invoice' => Invoice::class,
'successful_payment' => SuccessfulPayment::class,
'forward_signature' => true,
'author_signature' => true
];
/**
* Unique message identifier
*
* @var int
*/
protected $messageId;
/**
* Optional. Sender name. Can be empty for messages sent to channels
*
* @var \TelegramBot\Api\Types\User
*/
protected $from;
/**
* Date the message was sent in Unix time
*
* @var int
*/
protected $date;
/**
* Conversation the message belongs to — user in case of a private message, GroupChat in case of a group
*
* @var \TelegramBot\Api\Types\Chat
*/
protected $chat;
/**
* Optional. For forwarded messages, sender of the original message
*
* @var \TelegramBot\Api\Types\User
*/
protected $forwardFrom;
/**
* Optional. For forwarded messages, date the original message was sent in Unix time
*
* @var int
*/
protected $forwardDate;
/**
* 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.
*
* @var \TelegramBot\Api\Types\Message
*/
protected $replyToMessage;
/**
* Optional. For text messages, the actual UTF-8 text of the message
*
* @var string
*/
protected $text;
/**
* Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text.
* array of \TelegramBot\Api\Types\MessageEntity
*
* @var array
*/
protected $entities;
/**
* Optional. Message is an audio file, information about the file
*
* @var \TelegramBot\Api\Types\Audio
*/
protected $audio;
/**
* Optional. Message is a general file, information about the file
*
* @var \TelegramBot\Api\Types\Document
*/
protected $document;
/**
* Optional. Message is a photo, available sizes of the photo
* array of \TelegramBot\Api\Types\Photo
*
* @var array
*/
protected $photo;
/**
* Optional. Message is a sticker, information about the sticker
*
* @var \TelegramBot\Api\Types\Sticker
*/
protected $sticker;
/**
* Optional. Message is a video, information about the video
*
* @var \TelegramBot\Api\Types\Video
*/
protected $video;
/**
* Optional. Message is a voice message, information about the file
*
* @var \TelegramBot\Api\Types\Voice
*/
protected $voice;
/**
* Optional. Message is a shared contact, information about the contact
*
* @var \TelegramBot\Api\Types\Contact
*/
protected $contact;
/**
* Optional. Message is a shared location, information about the location
*
* @var \TelegramBot\Api\Types\Location
*/
protected $location;
/**
* Optional. Message is a venue, information about the venue
*
* @var \TelegramBot\Api\Types\Venue
*/
protected $venue;
/**
* Optional. A new member was added to the group, information about them (this member may be bot itself)
*
* @var \TelegramBot\Api\Types\User
*/
protected $newChatMember;
/**
* Optional. A member was removed from the group, information about them (this member may be bot itself)
*
* @var \TelegramBot\Api\Types\User
*/
protected $leftChatMember;
/**
* Optional. A group title was changed to this value
*
* @var string
*/
protected $newChatTitle;
/**
* Optional. A group photo was change to this value
*
* @var mixed
*/
protected $newChatPhoto;
/**
* Optional. Informs that the group photo was deleted
*
* @var bool
*/
protected $deleteChatPhoto;
/**
* Optional. Informs that the group has been created
*
* @var bool
*/
protected $groupChatCreated;
/**
* Optional. Text description of the video (usually empty)
*
* @var string
*/
protected $caption;
/**
* Optional. Service message: the supergroup has been created
*
* @var bool
*/
protected $supergroupChatCreated;
/**
* Optional. Service message: the channel has been created
*
* @var bool
*/
protected $channelChatCreated;
/**
* Optional. The group has been migrated to a supergroup with the specified identifier,
* not exceeding 1e13 by absolute value
*
* @var int
*/
protected $migrateToChatId;
/**
* Optional. The supergroup has been migrated from a group with the specified identifier,
* not exceeding 1e13 by absolute value
*
* @var int
*/
protected $migrateFromChatId;
/**
* Optional. Specified message was pinned.Note that the Message object in this field
* will not contain further reply_to_message fields even if it is itself a reply.
*
* @var Message
*/
protected $pinnedMessage;
/**
* Optional. Message is an invoice for a payment, information about the invoice.
*
* @var Invoice
*/
protected $invoice;
/**
* Optional. Message is a service message about a successful payment, information about the payment.
*
* @var SuccessfulPayment
*/
protected $successfulPayment;
/**
* Optional. For messages forwarded from channels, signature of the post author if present
*
* @var string
*/
protected $forwardSignature;
/**
* Optional. Signature of the post author for messages in channels
*
* @var string
*/
protected $authorSignature;
/**
* @return string
*/
public function getCaption()
{
return $this->caption;
}
/**
* @param string $caption
*/
public function setCaption($caption)
{
$this->caption = $caption;
}
/**
* @return Audio
*/
public function getAudio()
{
return $this->audio;
}
/**
* @param Audio $audio
*/
public function setAudio(Audio $audio)
{
$this->audio = $audio;
}
/**
* @return Chat
*/
public function getChat()
{
return $this->chat;
}
/**
* @param Chat $chat
*/
public function setChat(Chat $chat)
{
$this->chat = $chat;
}
/**
* @return Contact
*/
public function getContact()
{
return $this->contact;
}
/**
* @param Contact $contact
*/
public function setContact(Contact $contact)
{
$this->contact = $contact;
}
/**
* @return int
*/
public function getDate()
{
return $this->date;
}
/**
* @param int $date
*
* @throws InvalidArgumentException
*/
public function setDate($date)
{
if (is_integer($date)) {
$this->date = $date;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return boolean
*/
public function isDeleteChatPhoto()
{
return $this->deleteChatPhoto;
}
/**
* @param boolean $deleteChatPhoto
*/
public function setDeleteChatPhoto($deleteChatPhoto)
{
$this->deleteChatPhoto = (bool)$deleteChatPhoto;
}
/**
* @return Document
*/
public function getDocument()
{
return $this->document;
}
/**
* @param Document $document
*/
public function setDocument($document)
{
$this->document = $document;
}
/**
* @return int
*/
public function getForwardDate()
{
return $this->forwardDate;
}
/**
* @param int $forwardDate
*
* @throws InvalidArgumentException
*/
public function setForwardDate($forwardDate)
{
if (is_integer($forwardDate)) {
$this->forwardDate = $forwardDate;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return User
*/
public function getForwardFrom()
{
return $this->forwardFrom;
}
/**
* @param User $forwardFrom
*/
public function setForwardFrom(User $forwardFrom)
{
$this->forwardFrom = $forwardFrom;
}
/**
* @return boolean
*/
public function isGroupChatCreated()
{
return $this->groupChatCreated;
}
/**
* @param boolean $groupChatCreated
*/
public function setGroupChatCreated($groupChatCreated)
{
$this->groupChatCreated = (bool)$groupChatCreated;
}
/**
* @return User
*/
public function getLeftChatMember()
{
return $this->leftChatMember;
}
/**
* @param User $leftChatMember
*/
public function setLeftChatMember($leftChatMember)
{
$this->leftChatMember = $leftChatMember;
}
/**
* @return Location
*/
public function getLocation()
{
return $this->location;
}
/**
* @param Location $location
*/
public function setLocation(Location $location)
{
$this->location = $location;
}
/**
* @return Venue
*/
public function getVenue()
{
return $this->venue;
}
/**
* @param Venue $venue
*/
public function setVenue($venue)
{
$this->venue = $venue;
}
/**
* @return int
*/
public function getMessageId()
{
return $this->messageId;
}
/**
* @param int $messageId
*
* @throws InvalidArgumentException
*/
public function setMessageId($messageId)
{
if (is_integer($messageId) || is_float($messageId)) {
$this->messageId = $messageId;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return User
*/
public function getNewChatMember()
{
return $this->newChatMember;
}
/**
* @param User $newChatMember
*/
public function setNewChatMember($newChatMember)
{
$this->newChatMember = $newChatMember;
}
/**
* @return array
*/
public function getNewChatPhoto()
{
return $this->newChatPhoto;
}
/**
* @param array $newChatPhoto
*/
public function setNewChatPhoto($newChatPhoto)
{
$this->newChatPhoto = $newChatPhoto;
}
/**
* @return string
*/
public function getNewChatTitle()
{
return $this->newChatTitle;
}
/**
* @param string $newChatTitle
*/
public function setNewChatTitle($newChatTitle)
{
$this->newChatTitle = $newChatTitle;
}
/**
* @return array
*/
public function getPhoto()
{
return $this->photo;
}
/**
* @param array $photo
*/
public function setPhoto(array $photo)
{
$this->photo = $photo;
}
/**
* @return Message
*/
public function getReplyToMessage()
{
return $this->replyToMessage;
}
/**
* @param Message $replyToMessage
*/
public function setReplyToMessage(Message $replyToMessage)
{
$this->replyToMessage = $replyToMessage;
}
/**
* @return Sticker
*/
public function getSticker()
{
return $this->sticker;
}
/**
* @param Sticker $sticker
*/
public function setSticker(Sticker $sticker)
{
$this->sticker = $sticker;
}
/**
* @return string
*/
public function getText()
{
return $this->text;
}
/**
* @param string $text
*/
public function setText($text)
{
$this->text = $text;
}
/**
* @return array
*/
public function getEntities()
{
return $this->entities;
}
/**
* @param array $entities
*/
public function setEntities($entities)
{
$this->entities = $entities;
}
/**
* @return User
*/
public function getFrom()
{
return $this->from;
}
/**
* @param User $from
*/
public function setFrom(User $from)
{
$this->from = $from;
}
/**
* @return Video
*/
public function getVideo()
{
return $this->video;
}
/**
* @param Video $video
*/
public function setVideo(Video $video)
{
$this->video = $video;
}
/**
* @return Voice
*/
public function getVoice()
{
return $this->voice;
}
/**
* @param Voice $voice
*/
public function setVoice($voice)
{
$this->voice = $voice;
}
/**
* @param boolean $supergroupChatCreated
*/
public function setSupergroupChatCreated($supergroupChatCreated)
{
$this->supergroupChatCreated = $supergroupChatCreated;
}
/**
* @return boolean
*/
public function isSupergroupChatCreated()
{
return $this->supergroupChatCreated;
}
/**
* @param boolean $channelChatCreated
*/
public function setChannelChatCreated($channelChatCreated)
{
$this->channelChatCreated = $channelChatCreated;
}
/**
* @return boolean
*/
public function isChannelChatCreated()
{
return $this->channelChatCreated;
}
/**
* @param int $migrateToChatId
*/
public function setMigrateToChatId($migrateToChatId)
{
$this->migrateToChatId = $migrateToChatId;
}
/**
* @return int
*/
public function getMigrateToChatId()
{
return $this->migrateToChatId;
}
/**
* @param int $migrateFromChatId
*/
public function setMigrateFromChatId($migrateFromChatId)
{
$this->migrateFromChatId = $migrateFromChatId;
}
/**
* @return int
*/
public function getMigrateFromChatId()
{
return $this->migrateFromChatId;
}
/**
* @return Message
*/
public function getPinnedMessage()
{
return $this->pinnedMessage;
}
/**
* @param Message $pinnedMessage
*/
public function setPinnedMessage($pinnedMessage)
{
$this->pinnedMessage = $pinnedMessage;
}
/**
* @author MY
* @return Invoice
*/
public function getInvoice()
{
return $this->invoice;
}
/**
* @author MY
* @param Invoice $invoice
*/
public function setInvoice($invoice)
{
$this->invoice = $invoice;
}
/**
* @author MY
* @return SuccessfulPayment
*/
public function getSuccessfulPayment()
{
return $this->successfulPayment;
}
/**
* @author MY
* @param SuccessfulPayment $successfulPayment
*/
public function setSuccessfulPayment($successfulPayment)
{
$this->successfulPayment = $successfulPayment;
}
/**
* @return string
*/
public function getForwardSignature()
{
return $this->forwardSignature;
}
/**
* @param string $forwardSignature
*/
public function setForwardSignature($forwardSignature)
{
$this->forwardSignature = $forwardSignature;
}
/**
* @return string
*/
public function getAuthorSignature()
{
return $this->authorSignature;
}
/**
* @param string $authorSignature
*/
public function setAuthorSignature($authorSignature)
{
$this->authorSignature = $authorSignature;
}
}