6
6
use Zelenin \Telegram \Bot \Client \Client ;
7
7
use Zelenin \Telegram \Bot \Client \Response ;
8
8
use Zelenin \Telegram \Bot \Exception \NotOkException ;
9
+ use Zelenin \Telegram \Bot \Type \Chat ;
10
+ use Zelenin \Telegram \Bot \Type \ChatMember ;
9
11
use Zelenin \Telegram \Bot \Type \File ;
10
12
use Zelenin \Telegram \Bot \Type \Keyboard ;
11
13
use Zelenin \Telegram \Bot \Type \Message ;
@@ -40,6 +42,7 @@ public function request($method, array $params = [])
40
42
if (!$ response ->getOk ()) {
41
43
throw new NotOkException (sprintf ('Code: %s. Description: "%s". ' , $ response ->getErrorCode (), $ response ->getDescription ()));
42
44
}
45
+
43
46
return $ response ;
44
47
}
45
48
@@ -61,6 +64,7 @@ public function sendMessage(array $params)
61
64
if (isset ($ params ['reply_markup ' ]) && $ params ['reply_markup ' ] instanceof Keyboard) {
62
65
$ params ['reply_markup ' ] = json_encode ($ params ['reply_markup ' ]);
63
66
}
67
+
64
68
return Message::createFromResponse ($ this ->request ('sendMessage ' , $ params ));
65
69
}
66
70
@@ -84,6 +88,7 @@ public function sendPhoto(array $params)
84
88
if (isset ($ params ['reply_markup ' ]) && $ params ['reply_markup ' ] instanceof Keyboard) {
85
89
$ params ['reply_markup ' ] = json_encode ($ params ['reply_markup ' ]);
86
90
}
91
+
87
92
return Message::createFromResponse ($ this ->request ('sendPhoto ' , $ params ));
88
93
}
89
94
@@ -97,6 +102,7 @@ public function sendAudio(array $params)
97
102
if (isset ($ params ['reply_markup ' ]) && $ params ['reply_markup ' ] instanceof Keyboard) {
98
103
$ params ['reply_markup ' ] = json_encode ($ params ['reply_markup ' ]);
99
104
}
105
+
100
106
return Message::createFromResponse ($ this ->request ('sendAudio ' , $ params ));
101
107
}
102
108
@@ -110,6 +116,7 @@ public function sendDocument(array $params)
110
116
if (isset ($ params ['reply_markup ' ]) && $ params ['reply_markup ' ] instanceof Keyboard) {
111
117
$ params ['reply_markup ' ] = json_encode ($ params ['reply_markup ' ]);
112
118
}
119
+
113
120
return Message::createFromResponse ($ this ->request ('sendDocument ' , $ params ));
114
121
}
115
122
@@ -123,6 +130,7 @@ public function sendSticker(array $params)
123
130
if (isset ($ params ['reply_markup ' ]) && $ params ['reply_markup ' ] instanceof Keyboard) {
124
131
$ params ['reply_markup ' ] = json_encode ($ params ['reply_markup ' ]);
125
132
}
133
+
126
134
return Message::createFromResponse ($ this ->request ('sendSticker ' , $ params ));
127
135
}
128
136
@@ -136,6 +144,7 @@ public function sendVideo(array $params)
136
144
if (isset ($ params ['reply_markup ' ]) && $ params ['reply_markup ' ] instanceof Keyboard) {
137
145
$ params ['reply_markup ' ] = json_encode ($ params ['reply_markup ' ]);
138
146
}
147
+
139
148
return Message::createFromResponse ($ this ->request ('sendVideo ' , $ params ));
140
149
}
141
150
@@ -149,6 +158,7 @@ public function sendVoice(array $params)
149
158
if (isset ($ params ['reply_markup ' ]) && $ params ['reply_markup ' ] instanceof Keyboard) {
150
159
$ params ['reply_markup ' ] = json_encode ($ params ['reply_markup ' ]);
151
160
}
161
+
152
162
return Message::createFromResponse ($ this ->request ('sendVideo ' , $ params ));
153
163
}
154
164
@@ -162,6 +172,7 @@ public function sendLocation(array $params)
162
172
if (isset ($ params ['reply_markup ' ]) && $ params ['reply_markup ' ] instanceof Keyboard) {
163
173
$ params ['reply_markup ' ] = json_encode ($ params ['reply_markup ' ]);
164
174
}
175
+
165
176
return Message::createFromResponse ($ this ->request ('sendLocation ' , $ params ));
166
177
}
167
178
@@ -175,6 +186,7 @@ public function sendVenue(array $params)
175
186
if (isset ($ params ['reply_markup ' ]) && $ params ['reply_markup ' ] instanceof Keyboard) {
176
187
$ params ['reply_markup ' ] = json_encode ($ params ['reply_markup ' ]);
177
188
}
189
+
178
190
return Message::createFromResponse ($ this ->request ('sendVenue ' , $ params ));
179
191
}
180
192
@@ -188,6 +200,7 @@ public function sendContact(array $params)
188
200
if (isset ($ params ['reply_markup ' ]) && $ params ['reply_markup ' ] instanceof Keyboard) {
189
201
$ params ['reply_markup ' ] = json_encode ($ params ['reply_markup ' ]);
190
202
}
203
+
191
204
return Message::createFromResponse ($ this ->request ('sendContact ' , $ params ));
192
205
}
193
206
@@ -226,9 +239,19 @@ public function getFile(array $params)
226
239
*
227
240
* @return Response
228
241
*/
229
- public function answerCallbackQuery (array $ params )
242
+ public function kickChatMember (array $ params )
230
243
{
231
- return $ this ->request ('answerCallbackQuery ' , $ params );
244
+ return $ this ->request ('kickChatMember ' , $ params );
245
+ }
246
+
247
+ /**
248
+ * @param array $params
249
+ *
250
+ * @return Response
251
+ */
252
+ public function leaveChat (array $ params )
253
+ {
254
+ return $ this ->request ('leaveChat ' , $ params );
232
255
}
233
256
234
257
/**
@@ -241,14 +264,56 @@ public function unbanChatMember(array $params)
241
264
return $ this ->request ('unbanChatMember ' , $ params );
242
265
}
243
266
267
+ /**
268
+ * @param array $params
269
+ *
270
+ * @return Chat
271
+ */
272
+ public function getChat (array $ params )
273
+ {
274
+ return Chat::createFromResponse ($ this ->request ('getChat ' , $ params ));
275
+ }
276
+
277
+ /**
278
+ * @param array $params
279
+ *
280
+ * @return ChatMember[]
281
+ */
282
+ public function getChatAdministrators (array $ params )
283
+ {
284
+ return array_map (function ($ user ) {
285
+ return ChatMember::create ($ user );
286
+ }, $ this ->request ('getChatAdministrators ' , $ params )->getResult ());
287
+ }
288
+
244
289
/**
245
290
* @param array $params
246
291
*
247
292
* @return Response
248
293
*/
249
- public function kickChatMember (array $ params )
294
+ public function getChatMembersCount (array $ params )
250
295
{
251
- return $ this ->request ('kickChatMember ' , $ params );
296
+ return $ this ->request ('getChatMembersCount ' , $ params );
297
+ }
298
+
299
+ /**
300
+ * @param array $params
301
+ *
302
+ * @return ChatMember
303
+ */
304
+ public function getChatMember (array $ params )
305
+ {
306
+ return ChatMember::createFromResponse ($ this ->request ('getChatMember ' , $ params )->getResult ());
307
+ }
308
+
309
+ /**
310
+ * @param array $params
311
+ *
312
+ * @return Response
313
+ */
314
+ public function answerCallbackQuery (array $ params )
315
+ {
316
+ return $ this ->request ('answerCallbackQuery ' , $ params );
252
317
}
253
318
254
319
/**
@@ -261,6 +326,7 @@ public function editMessageText(array $params)
261
326
if (isset ($ params ['reply_markup ' ]) && $ params ['reply_markup ' ] instanceof Keyboard) {
262
327
$ params ['reply_markup ' ] = json_encode ($ params ['reply_markup ' ]);
263
328
}
329
+
264
330
return Message::createFromResponse ($ this ->request ('editMessageText ' , $ params ));
265
331
}
266
332
@@ -274,6 +340,7 @@ public function editMessageCaption(array $params = [])
274
340
if (isset ($ params ['reply_markup ' ]) && $ params ['reply_markup ' ] instanceof Keyboard) {
275
341
$ params ['reply_markup ' ] = json_encode ($ params ['reply_markup ' ]);
276
342
}
343
+
277
344
return Message::createFromResponse ($ this ->request ('editMessageCaption ' , $ params ));
278
345
}
279
346
@@ -287,6 +354,7 @@ public function editMessageReplyMarkup(array $params = [])
287
354
if (isset ($ params ['reply_markup ' ]) && $ params ['reply_markup ' ] instanceof Keyboard) {
288
355
$ params ['reply_markup ' ] = json_encode ($ params ['reply_markup ' ]);
289
356
}
357
+
290
358
return Message::createFromResponse ($ this ->request ('editMessageReplyMarkup ' , $ params ));
291
359
}
292
360
0 commit comments