1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Class that represents Telegram's Bot-API "sendMessage" method. |
5
|
|
|
* |
6
|
|
|
* @package Teebot (Telegram bot framework) |
7
|
|
|
* |
8
|
|
|
* @author Stanislav Drozdov <[email protected]> |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Teebot\Method; |
12
|
|
|
|
13
|
|
|
use Teebot\Entity\Message; |
14
|
|
|
|
15
|
|
|
class SendMessage extends AbstractMethod |
16
|
|
|
{ |
17
|
|
|
const NAME = 'sendMessage'; |
18
|
|
|
|
19
|
|
|
const RETURN_ENTITY = Message::class; |
20
|
|
|
|
21
|
|
|
const PARSE_MODE_MARKDOWN = 'Markdown'; |
22
|
|
|
|
23
|
|
|
const PARSE_MODE_HTML = 'HTML'; |
24
|
|
|
|
25
|
|
|
protected $chat_id; |
26
|
|
|
|
27
|
|
|
protected $text; |
28
|
|
|
|
29
|
|
|
protected $parse_mode; |
30
|
|
|
|
31
|
|
|
protected $disable_web_page_preview; |
32
|
|
|
|
33
|
|
|
protected $disable_notification; |
34
|
|
|
|
35
|
|
|
protected $reply_to_message_id; |
36
|
|
|
|
37
|
|
|
protected $reply_markup; |
38
|
|
|
|
39
|
|
|
protected $supportedProperties = [ |
40
|
|
|
'chat_id' => true, |
41
|
|
|
'text' => true, |
42
|
|
|
'parse_mode' => false, |
43
|
|
|
'disable_web_page_preview' => false, |
44
|
|
|
'disable_notification' => false, |
45
|
|
|
'reply_to_message_id' => false, |
46
|
|
|
'reply_markup' => false, |
47
|
|
|
]; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return mixed |
51
|
|
|
*/ |
52
|
|
|
public function getChatId() |
53
|
|
|
{ |
54
|
|
|
return $this->chat_id; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param mixed $chat_id |
59
|
|
|
* |
60
|
|
|
* @return $this |
61
|
|
|
*/ |
62
|
|
|
public function setChatId($chat_id) |
63
|
|
|
{ |
64
|
|
|
$this->chat_id = $chat_id; |
65
|
|
|
|
66
|
|
|
return $this; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return mixed |
71
|
|
|
*/ |
72
|
|
|
public function getText() |
73
|
|
|
{ |
74
|
|
|
return $this->text; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param mixed $text |
79
|
|
|
* |
80
|
|
|
* @return $this |
81
|
|
|
*/ |
82
|
|
|
public function setText($text) |
83
|
|
|
{ |
84
|
|
|
$this->text = $text; |
85
|
|
|
|
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return mixed |
91
|
|
|
*/ |
92
|
|
|
public function getParseMode() |
93
|
|
|
{ |
94
|
|
|
return $this->parse_mode; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @param mixed $parse_mode |
99
|
|
|
* |
100
|
|
|
* @return $this |
101
|
|
|
*/ |
102
|
|
|
public function setParseMode($parse_mode) |
103
|
|
|
{ |
104
|
|
|
$this->parse_mode = $parse_mode; |
105
|
|
|
|
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @return $this |
111
|
|
|
*/ |
112
|
|
|
public function setHTMLParseMode() |
113
|
|
|
{ |
114
|
|
|
$this->parse_mode = static::PARSE_MODE_HTML; |
115
|
|
|
|
116
|
|
|
return $this; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return $this |
121
|
|
|
*/ |
122
|
|
|
public function setMarkdownParseMode() |
123
|
|
|
{ |
124
|
|
|
$this->parse_mode = static::PARSE_MODE_MARKDOWN; |
125
|
|
|
|
126
|
|
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return mixed |
131
|
|
|
*/ |
132
|
|
|
public function getDisableWebPagePreview() |
133
|
|
|
{ |
134
|
|
|
return $this->disable_web_page_preview; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @param mixed $disable_web_page_preview |
139
|
|
|
* |
140
|
|
|
* @return $this |
141
|
|
|
*/ |
142
|
|
|
public function setDisableWebPagePreview($disable_web_page_preview) |
143
|
|
|
{ |
144
|
|
|
$this->disable_web_page_preview = $disable_web_page_preview; |
145
|
|
|
|
146
|
|
|
return $this; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @return mixed |
151
|
|
|
*/ |
152
|
|
|
public function getDisableNotification() |
153
|
|
|
{ |
154
|
|
|
return $this->disable_notification; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @param mixed $disable_notification |
159
|
|
|
* |
160
|
|
|
* @return $this |
161
|
|
|
*/ |
162
|
|
|
public function setDisableNotification($disable_notification) |
163
|
|
|
{ |
164
|
|
|
$this->disable_notification = $disable_notification; |
165
|
|
|
|
166
|
|
|
return $this; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return mixed |
171
|
|
|
*/ |
172
|
|
|
public function getReplyToMessageId() |
173
|
|
|
{ |
174
|
|
|
return $this->reply_to_message_id; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @param mixed $reply_to_message_id |
179
|
|
|
* |
180
|
|
|
* @return $this |
181
|
|
|
*/ |
182
|
|
|
public function setReplyToMessageId($reply_to_message_id) |
183
|
|
|
{ |
184
|
|
|
$this->reply_to_message_id = $reply_to_message_id; |
185
|
|
|
|
186
|
|
|
return $this; |
187
|
|
|
} |
188
|
|
|
} |
189
|
|
|
|