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\SendDiceMethod; |
14
|
|
|
use TgBotApi\BotApiBase\Method\SendDocumentMethod; |
15
|
|
|
use TgBotApi\BotApiBase\Method\SendGameMethod; |
16
|
|
|
use TgBotApi\BotApiBase\Method\SendInvoiceMethod; |
17
|
|
|
use TgBotApi\BotApiBase\Method\SendLocationMethod; |
18
|
|
|
use TgBotApi\BotApiBase\Method\SendMediaGroupMethod; |
19
|
|
|
use TgBotApi\BotApiBase\Method\SendMessageMethod; |
20
|
|
|
use TgBotApi\BotApiBase\Method\SendPhotoMethod; |
21
|
|
|
use TgBotApi\BotApiBase\Method\SendPollMethod; |
22
|
|
|
use TgBotApi\BotApiBase\Method\SendStickerMethod; |
23
|
|
|
use TgBotApi\BotApiBase\Method\SendVenueMethod; |
24
|
|
|
use TgBotApi\BotApiBase\Method\SendVideoMethod; |
25
|
|
|
use TgBotApi\BotApiBase\Method\SendVideoNoteMethod; |
26
|
|
|
use TgBotApi\BotApiBase\Method\SendVoiceMethod; |
27
|
|
|
use TgBotApi\BotApiBase\Type\MessageType; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Trait SendMethodTrait. |
31
|
|
|
*/ |
32
|
|
|
trait SendMethodTrait |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @throws ResponseException |
36
|
|
|
* |
37
|
|
|
* @return MessageType[] |
38
|
|
|
*/ |
39
|
|
|
abstract public function sendMediaGroup(SendMediaGroupMethod $method): array; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @throws ResponseException |
43
|
|
|
*/ |
44
|
|
|
abstract public function send(SendMethodAliasInterface $method): MessageType; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @throws ResponseException |
48
|
|
|
*/ |
49
|
|
|
abstract public function sendChatAction(SendChatActionMethod $method): bool; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @throws ResponseException |
53
|
|
|
*/ |
54
|
2 |
|
public function sendPhoto(SendPhotoMethod $method): MessageType |
55
|
|
|
{ |
56
|
2 |
|
return $this->send($method); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @throws ResponseException |
61
|
|
|
*/ |
62
|
2 |
|
public function sendAudio(SendAudioMethod $method): MessageType |
63
|
|
|
{ |
64
|
2 |
|
return $this->send($method); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @throws ResponseException |
69
|
|
|
*/ |
70
|
2 |
|
public function sendDocument(SendDocumentMethod $method): MessageType |
71
|
|
|
{ |
72
|
2 |
|
return $this->send($method); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @throws ResponseException |
77
|
|
|
*/ |
78
|
2 |
|
public function sendVideo(SendVideoMethod $method): MessageType |
79
|
|
|
{ |
80
|
2 |
|
return $this->send($method); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @throws ResponseException |
85
|
|
|
*/ |
86
|
2 |
|
public function sendAnimation(SendAnimationMethod $method): MessageType |
87
|
|
|
{ |
88
|
2 |
|
return $this->send($method); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @throws ResponseException |
93
|
|
|
*/ |
94
|
2 |
|
public function sendVoice(SendVoiceMethod $method): MessageType |
95
|
|
|
{ |
96
|
2 |
|
return $this->send($method); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @throws ResponseException |
101
|
|
|
*/ |
102
|
2 |
|
public function sendVideoNote(SendVideoNoteMethod $method): MessageType |
103
|
|
|
{ |
104
|
2 |
|
return $this->send($method); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @throws ResponseException |
109
|
|
|
*/ |
110
|
1 |
|
public function sendGame(SendGameMethod $method): MessageType |
111
|
|
|
{ |
112
|
1 |
|
return $this->send($method); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @throws ResponseException |
117
|
|
|
*/ |
118
|
1 |
|
public function sendInvoice(SendInvoiceMethod $method): MessageType |
119
|
|
|
{ |
120
|
1 |
|
return $this->send($method); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @throws ResponseException |
125
|
|
|
*/ |
126
|
2 |
|
public function sendLocation(SendLocationMethod $method): MessageType |
127
|
|
|
{ |
128
|
2 |
|
return $this->send($method); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @throws ResponseException |
133
|
|
|
*/ |
134
|
2 |
|
public function sendVenue(SendVenueMethod $method): MessageType |
135
|
|
|
{ |
136
|
2 |
|
return $this->send($method); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @throws ResponseException |
141
|
|
|
*/ |
142
|
2 |
|
public function sendContact(SendContactMethod $method): MessageType |
143
|
|
|
{ |
144
|
2 |
|
return $this->send($method); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @throws ResponseException |
149
|
|
|
*/ |
150
|
1 |
|
public function sendDice(SendDiceMethod $method): MessageType |
151
|
|
|
{ |
152
|
1 |
|
return $this->send($method); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @throws ResponseException |
157
|
|
|
*/ |
158
|
1 |
|
public function sendSticker(SendStickerMethod $method): MessageType |
159
|
|
|
{ |
160
|
1 |
|
return $this->send($method); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @throws ResponseException |
165
|
|
|
*/ |
166
|
2 |
|
public function sendMessage(SendMessageMethod $method): MessageType |
167
|
|
|
{ |
168
|
2 |
|
return $this->send($method); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @throws ResponseException |
173
|
|
|
*/ |
174
|
1 |
|
public function sendPoll(SendPollMethod $method): MessageType |
175
|
|
|
{ |
176
|
1 |
|
return $this->send($method); |
177
|
|
|
} |
178
|
|
|
} |
179
|
|
|
|