1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Telegram\Bot\Objects; |
4
|
|
|
|
5
|
|
|
use Telegram\Bot\Helpers\Emojify; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class Message. |
9
|
|
|
* |
10
|
|
|
* |
11
|
|
|
* @method int getMessageId() Unique message identifier. |
12
|
|
|
* @method User getFrom() (Optional). Sender, can be empty for messages sent to channels. |
13
|
|
|
* @method int getDate() Date the message was sent in Unix time. |
14
|
|
|
* @method Chat getChat() Conversation the message belongs to. |
15
|
|
|
* @method User getForwardFrom() (Optional). For forwarded messages, sender of the original message. |
16
|
|
|
* @method int getForwardDate() (Optional). For forwarded messages, date the original message was sent in Unix time. |
17
|
|
|
* @method Message getReplyToMessage() (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. |
18
|
|
|
* @method MessageEntity[] getEntities() (Optional). For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text. |
19
|
|
|
* @method Audio getAudio() (Optional). Message is an audio file, information about the file. |
20
|
|
|
* @method Document getDocument() (Optional). Message is a general file, information about the file. |
21
|
|
|
* @method PhotoSize[] getPhoto() (Optional). Message is a photo, available sizes of the photo. |
22
|
|
|
* @method Sticker getSticker() (Optional). Message is a sticker, information about the sticker. |
23
|
|
|
* @method Video getVideo() (Optional). Message is a video, information about the video. |
24
|
|
|
* @method Voice getVoice() (Optional). Message is a voice message, information about the file. |
25
|
|
|
* @method Contact getContact() (Optional). Message is a shared contact, information about the contact. |
26
|
|
|
* @method Location getLocation() (Optional). Message is a shared location, information about the location. |
27
|
|
|
* @method Venue getVenue() (Optional). Message is a venue, information about the venue. |
28
|
|
|
* @method User getNewChatMember() (Optional). A new member was added to the group, information about them (this member may be the bot itself). |
29
|
|
|
* @method User getLeftChatMember() (Optional). A member was removed from the group, information about them (this member may be the bot itself). |
30
|
|
|
* @method string getNewChatTitle() (Optional). A chat title was changed to this value. |
31
|
|
|
* @method PhotoSize[] getNewChatPhoto() (Optional). A chat photo was change to this value. |
32
|
|
|
* @method bool getDeleteChatPhoto() (Optional). Service message: the chat photo was deleted. |
33
|
|
|
* @method bool getGroupChatCreated() (Optional). Service message: the group has been created. |
34
|
|
|
* @method bool getSupergroupChatCreated() (Optional). Service message: the super group has been created. |
35
|
|
|
* @method bool getChannelChatCreated() (Optional). Service message: the channel has been created. |
36
|
|
|
* @method int getMigrateToChatId() (Optional). The group has been migrated to a supergroup with the specified identifier, not exceeding 1e13 by absolute value. |
37
|
|
|
* @method int getMigrateFromChatId() (Optional). The supergroup has been migrated from a group with the specified identifier, not exceeding 1e13 by absolute value. |
38
|
|
|
* @method Message getPinnedMessage() (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. |
39
|
|
|
*/ |
40
|
|
|
class Message extends BaseObject |
41
|
|
|
{ |
42
|
|
|
/** |
43
|
|
|
* {@inheritdoc} |
44
|
|
|
*/ |
45
|
30 |
|
public function relations() |
46
|
|
|
{ |
47
|
|
|
return [ |
48
|
30 |
|
'from' => User::class, |
49
|
30 |
|
'chat' => Chat::class, |
50
|
30 |
|
'forward_from' => User::class, |
51
|
30 |
|
'reply_to_message' => self::class, |
52
|
30 |
|
'entities' => MessageEntity::class, |
53
|
30 |
|
'audio' => Audio::class, |
54
|
30 |
|
'document' => Document::class, |
55
|
30 |
|
'photo' => PhotoSize::class, |
56
|
30 |
|
'sticker' => Sticker::class, |
57
|
30 |
|
'video' => Video::class, |
58
|
30 |
|
'voice' => Voice::class, |
59
|
30 |
|
'contact' => Contact::class, |
60
|
30 |
|
'location' => Location::class, |
61
|
30 |
|
'venue' => Venue::class, |
62
|
30 |
|
'new_chat_member' => User::class, |
63
|
30 |
|
'left_chat_member' => User::class, |
64
|
30 |
|
'new_chat_photo' => PhotoSize::class, |
65
|
30 |
|
'pinned_message' => Message::class, |
66
|
30 |
|
]; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* (Optional). For text messages, the actual UTF-8 text of the message. |
71
|
|
|
* |
72
|
|
|
* @return string |
73
|
|
|
*/ |
74
|
8 |
|
public function getText() |
75
|
|
|
{ |
76
|
8 |
|
return Emojify::translate($this->get('text')); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* (Optional). Caption for the document, photo or video contact. |
81
|
|
|
* |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
|
|
public function getCaption() |
85
|
|
|
{ |
86
|
|
|
return Emojify::translate($this->get('caption')); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
} |
90
|
|
|
|