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