1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace TgBotApi\BotApiBase\Traits; |
6
|
|
|
|
7
|
|
|
use TgBotApi\BotApiBase\Exception\ResponseException; |
8
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\SendMethodAliasInterface; |
9
|
|
|
use TgBotApi\BotApiBase\Method\SendAnimationMethod; |
10
|
|
|
use TgBotApi\BotApiBase\Method\SendAudioMethod; |
11
|
|
|
use TgBotApi\BotApiBase\Method\SendChatActionMethod; |
12
|
|
|
use TgBotApi\BotApiBase\Method\SendContactMethod; |
13
|
|
|
use TgBotApi\BotApiBase\Method\SendDocumentMethod; |
14
|
|
|
use TgBotApi\BotApiBase\Method\SendGameMethod; |
15
|
|
|
use TgBotApi\BotApiBase\Method\SendInvoiceMethod; |
16
|
|
|
use TgBotApi\BotApiBase\Method\SendLocationMethod; |
17
|
|
|
use TgBotApi\BotApiBase\Method\SendMediaGroupMethod; |
18
|
|
|
use TgBotApi\BotApiBase\Method\SendMessageMethod; |
19
|
|
|
use TgBotApi\BotApiBase\Method\SendPhotoMethod; |
20
|
|
|
use TgBotApi\BotApiBase\Method\SendPollMethod; |
21
|
|
|
use TgBotApi\BotApiBase\Method\SendStickerMethod; |
22
|
|
|
use TgBotApi\BotApiBase\Method\SendVenueMethod; |
23
|
|
|
use TgBotApi\BotApiBase\Method\SendVideoMethod; |
24
|
|
|
use TgBotApi\BotApiBase\Method\SendVideoNoteMethod; |
25
|
|
|
use TgBotApi\BotApiBase\Method\SendVoiceMethod; |
26
|
|
|
use TgBotApi\BotApiBase\Type\MessageType; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Trait SendMethodTrait. |
30
|
|
|
*/ |
31
|
|
|
trait SendMethodTrait |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* @param SendMediaGroupMethod $method |
35
|
|
|
* |
36
|
|
|
* @throws ResponseException |
37
|
|
|
* |
38
|
|
|
* @return MessageType[] |
39
|
|
|
*/ |
40
|
|
|
abstract public function sendMediaGroup(SendMediaGroupMethod $method): array; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param SendMethodAliasInterface $method |
44
|
|
|
* |
45
|
|
|
* @throws ResponseException |
46
|
|
|
* |
47
|
|
|
* @return MessageType |
48
|
|
|
*/ |
49
|
|
|
abstract public function send(SendMethodAliasInterface $method): MessageType; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param SendChatActionMethod $method |
53
|
|
|
* |
54
|
|
|
* @throws ResponseException |
55
|
|
|
* |
56
|
|
|
* @return bool |
57
|
|
|
*/ |
58
|
|
|
abstract public function sendChatAction(SendChatActionMethod $method): bool; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param SendPhotoMethod $method |
62
|
|
|
* |
63
|
|
|
* @throws ResponseException |
64
|
|
|
* |
65
|
|
|
* @return MessageType |
66
|
|
|
*/ |
67
|
6 |
|
public function sendPhoto(SendPhotoMethod $method): MessageType |
68
|
|
|
{ |
69
|
6 |
|
return $this->send($method); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param SendAudioMethod $method |
74
|
|
|
* |
75
|
|
|
* @throws ResponseException |
76
|
|
|
* |
77
|
|
|
* @return MessageType |
78
|
|
|
*/ |
79
|
6 |
|
public function sendAudio(SendAudioMethod $method): MessageType |
80
|
|
|
{ |
81
|
6 |
|
return $this->send($method); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param SendDocumentMethod $method |
86
|
|
|
* |
87
|
|
|
* @throws ResponseException |
88
|
|
|
* |
89
|
|
|
* @return MessageType |
90
|
|
|
*/ |
91
|
6 |
|
public function sendDocument(SendDocumentMethod $method): MessageType |
92
|
|
|
{ |
93
|
6 |
|
return $this->send($method); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param SendVideoMethod $method |
98
|
|
|
* |
99
|
|
|
* @throws ResponseException |
100
|
|
|
* |
101
|
|
|
* @return MessageType |
102
|
|
|
*/ |
103
|
6 |
|
public function sendVideo(SendVideoMethod $method): MessageType |
104
|
|
|
{ |
105
|
6 |
|
return $this->send($method); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param SendAnimationMethod $method |
110
|
|
|
* |
111
|
|
|
* @throws ResponseException |
112
|
|
|
* |
113
|
|
|
* @return MessageType |
114
|
|
|
*/ |
115
|
6 |
|
public function sendAnimation(SendAnimationMethod $method): MessageType |
116
|
|
|
{ |
117
|
6 |
|
return $this->send($method); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @param SendVoiceMethod $method |
122
|
|
|
* |
123
|
|
|
* @throws ResponseException |
124
|
|
|
* |
125
|
|
|
* @return MessageType |
126
|
|
|
*/ |
127
|
6 |
|
public function sendVoice(SendVoiceMethod $method): MessageType |
128
|
|
|
{ |
129
|
6 |
|
return $this->send($method); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @param SendVideoNoteMethod $method |
134
|
|
|
* |
135
|
|
|
* @throws ResponseException |
136
|
|
|
* |
137
|
|
|
* @return MessageType |
138
|
|
|
*/ |
139
|
6 |
|
public function sendVideoNote(SendVideoNoteMethod $method): MessageType |
140
|
|
|
{ |
141
|
6 |
|
return $this->send($method); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @param SendGameMethod $method |
146
|
|
|
* |
147
|
|
|
* @throws ResponseException |
148
|
|
|
* |
149
|
|
|
* @return MessageType |
150
|
|
|
*/ |
151
|
3 |
|
public function sendGame(SendGameMethod $method): MessageType |
152
|
|
|
{ |
153
|
3 |
|
return $this->send($method); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @param SendInvoiceMethod $method |
158
|
|
|
* |
159
|
|
|
* @throws ResponseException |
160
|
|
|
* |
161
|
|
|
* @return MessageType |
162
|
|
|
*/ |
163
|
3 |
|
public function sendInvoice(SendInvoiceMethod $method): MessageType |
164
|
|
|
{ |
165
|
3 |
|
return $this->send($method); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @param SendLocationMethod $method |
170
|
|
|
* |
171
|
|
|
* @throws ResponseException |
172
|
|
|
* |
173
|
|
|
* @return MessageType |
174
|
|
|
*/ |
175
|
6 |
|
public function sendLocation(SendLocationMethod $method): MessageType |
176
|
|
|
{ |
177
|
6 |
|
return $this->send($method); |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @param SendVenueMethod $method |
182
|
|
|
* |
183
|
|
|
* @throws ResponseException |
184
|
|
|
* |
185
|
|
|
* @return MessageType |
186
|
|
|
*/ |
187
|
6 |
|
public function sendVenue(SendVenueMethod $method): MessageType |
188
|
|
|
{ |
189
|
6 |
|
return $this->send($method); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @param SendContactMethod $method |
194
|
|
|
* |
195
|
|
|
* @throws ResponseException |
196
|
|
|
* |
197
|
|
|
* @return MessageType |
198
|
|
|
*/ |
199
|
6 |
|
public function sendContact(SendContactMethod $method): MessageType |
200
|
|
|
{ |
201
|
6 |
|
return $this->send($method); |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @param SendStickerMethod $method |
206
|
|
|
* |
207
|
|
|
* @throws ResponseException |
208
|
|
|
* |
209
|
|
|
* @return MessageType |
210
|
|
|
*/ |
211
|
3 |
|
public function sendSticker(SendStickerMethod $method): MessageType |
212
|
|
|
{ |
213
|
3 |
|
return $this->send($method); |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @param SendMessageMethod $method |
218
|
|
|
* |
219
|
|
|
* @throws ResponseException |
220
|
|
|
* |
221
|
|
|
* @return MessageType |
222
|
|
|
*/ |
223
|
6 |
|
public function sendMessage(SendMessageMethod $method): MessageType |
224
|
|
|
{ |
225
|
6 |
|
return $this->send($method); |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @param SendPollMethod $method |
230
|
|
|
* |
231
|
|
|
* @throws ResponseException |
232
|
|
|
* |
233
|
|
|
* @return MessageType |
234
|
|
|
*/ |
235
|
3 |
|
public function sendPoll(SendPollMethod $method): MessageType |
236
|
|
|
{ |
237
|
3 |
|
return $this->send($method); |
238
|
|
|
} |
239
|
|
|
} |
240
|
|
|
|