forked from akbarjoudi/yii2-bot-telegram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTelegram.php
833 lines (775 loc) · 26.6 KB
/
Telegram.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
<?php /** @noinspection PhpUnused, GrazieInspection */
namespace aki\telegram;
use aki\telegram\base\Response;
use aki\telegram\base\TelegramBase;
use GuzzleHttp\Exception\GuzzleException;
/**
* @author Akbar Joudi <akbar.joody@gmail.com>
*/
class Telegram extends TelegramBase
{
/**
* getMe information
* @throws GuzzleException
*/
public function getMe(): Response
{
$body = $this->send('/getMe');
return new Response([
'ok' => $body['ok'],
'result' => [
'user' => $body['result']
]
]);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->sendMessage([
* 'chat_id' => $chat_id,
* 'text' => 'test',
* 'reply_markup' => json_encode($reply_markup)
* 'reply_to_message_id' => $reply_to_message_id,
* 'disable_web_page_preview' => $disable_web_page_preview,
* ]);
*/
public function sendMessage(array $params): Response
{
$body = $this->send('/sendMessage', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->sendPhoto([
* 'chat_id' => $chat_id,
* 'photo' => 'path/to/test.jpg',//realpath
* 'caption' => $caption,
* 'reply_to_message_id' => $reply_to_message_id,
* 'reply_markup' => $reply_markup
* ]);
*/
public function sendPhoto(array $params): Response
{
$body = $this->send('/sendPhoto', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->forwardMessage([
* 'chat_id' => $chat_id,
* 'from_chat_id' => $from_chat_id,
* 'message_id' => $message_id,
* ]);
*/
public function forwardMessage(array $params): Response
{
$body = $this->send('/forwardMessage', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->sendAudio[
* 'chat_id' => $chat_id,
* 'audio' => 'path/to/test.ogg',//realpath
* 'caption' => '',
* 'duration' => 0,
* 'reply_to_message_id' => $reply_to_message_id,
* 'reply_markup' => $reply_markup
* ]);
*/
public function sendAudio(array $params): Response
{
$body = $this->send('/sendAudio', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->sendDocument([
* 'chat_id' => $chat_id,
* 'document' => 'path/to/test.pdf',//realpath
* 'caption' => '',
* 'reply_to_message_id' => $reply_to_message_id,
* 'reply_markup' => $reply_markup
* ]);
*/
public function sendDocument(array $params): Response
{
$body = $this->send('/sendDocument', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->sendSticker([
* 'chat_id' => $chat_id,
* 'sticker' => 'path/to/test.webp',//realpath
* 'reply_to_message_id' => $reply_to_message_id,
* 'reply_markup' => $reply_markup
* ]);
*/
public function sendSticker(array $params): Response
{
$body = $this->send('/sendSticker', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->sendSticker([
* 'chat_id' => $chat_id,
* 'voice' => InputFile or String
* 'caption' => String,
* 'parse_mode' => parse_mode,
* 'duration' => Integer,
* 'disable_notification' => Boolean,
* 'reply_to_message_id' => Integer,
* 'reply_markup' => InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply
* ]);
*/
public function sendVoice(array $params): Response
{
$body = $this->send('/sendVoice', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->sendSticker([
* 'chat_id' => $chat_id,
* 'video_note' => InputFile or String
* 'thumb' => InputFile or String,
* 'duration' => Integer,
* 'duration' => Integer
* 'disable_notification' => Boolean,
* 'reply_to_message_id' => Integer,
* 'reply_markup' => InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply
* ]);
*/
public function sendVideoNote(array $params): Response
{
$body = $this->send('/sendVideoNote', $params);
return new Response($body);
}
/**
* @return Response
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->sendVideo([
* 'chat_id' => $chat_id,
* 'video' => 'path/to/test.mp4',//realpath
* 'duration' => 0,
* 'width' => Integer,//Video width
* 'height' => Integer, //Video height
* 'caption' => $caption,
* 'reply_to_message_id' => $reply_to_message_id,
* 'reply_markup' => $reply_markup,
* 'thumb' => InputFile or String,
* 'supports_streaming' => Boolean, //Pass True, if the uploaded video is suitable for streaming
* 'disable_notification' => Boolean,//Sends the message silently. Users will receive a notification with no sound.
* ]);
*/
public function sendVideo(array $params): Response
{
$body = $this->send('/sendVideo', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->sendLocation([
* 'chat_id' => $chat_id,
* 'latitude' => 37.7576793,
* 'longitude' => -122.5076402,
* 'disable_notification' => true,//true||false,
* 'reply_to_message_id' => $reply_to_message_id,
* 'reply_markup' => $reply_markup
* ]);
*/
public function sendLocation(array $params): Response
{
$body = $this->send('/sendLocation', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->editMessageLiveLocation([
* 'chat_id' => $chat_id,
* 'message_id' => 132121,
* 'inline_message_id' => 321344,
* 'latitude' => 123.4
* 'longitude' => 123.4,
* 'reply_markup' => InlineKeyboardMarkup
* ]);
*/
public function editMessageLiveLocation(array $params): Response
{
$body = $this->send('/editMessageLiveLocation', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->stopMessageLiveLocation([
* 'chat_id' => $chat_id,
* 'message_id' => 132121,
* 'inline_message_id' => 321344,
* 'reply_markup' => InlineKeyboardMarkup
* ]);
*/
public function stopMessageLiveLocation(array $params): Response
{
$body = $this->send('/stopMessageLiveLocation', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->sendChatAction([
* 'chat_id' => $chat_id,
* 'action' => 'upload_photo',// upload_photo or record_video or upload_video or record_audio or
* // upload_audio or upload_document or find_location
* ]);
*
*/
public function sendChatAction(array $params): Response
{
$body = $this->send('/sendChatAction', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->getUserProfilePhotos([
* 'user_id' => $chat_id,
* 'offset' => $offset,//Sequential number of the first photo to be returned. By default, all photos are returned.
* 'limit' => $limit, //Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100.
* ]);
*
*/
public function getUserProfilePhotos($params): Response
{
$body = $this->send('/getUserProfilePhotos', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->getUpdates([
* 'offset' => $offset,//Identifier of the first update to be returned. Must be greater by one than the highest among the * //identifiers of previously received updates.
* //By default, updates starting with the earliest unconfirmed update are returned.
* //An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id.
* //The negative offset can be specified to retrieve updates starting from -offset
* //update from the end of the updates queue.
* 'limit' => $limit,//Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100.
* 'timeout' => $timeout,//Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling
* ]);
*
*/
public function getUpdates(array $params = [])
{
return $this->send('/getUpdates', $params);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->setWebhook([
* 'url' => $url,
* ]);
*
*/
public function setWebhook(array $params = [])
{
return $this->send('/setWebhook', $params);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->deleteWebhook();
*
*/
public function deleteWebhook(array $params = [])
{
return $this->send('/deleteWebhook', $params);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->getChat([
* 'chat_id' => '3343545121',
* ]);
*
*/
public function getChat(array $params = []): Response
{
$body = $this->send('/getChat', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->getChatAdministrators([
* 'chat_id' => '3343545121',
* ]);
* Use this method to get a list of administrators in a chat.
*/
public function getChatAdministrators(array $params = []): Response
{
$body = $this->send('/getChatAdministrators', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->getChatMembersCount([
* 'chat_id' => '3343545121',
* ]);
* Use this method to get the number of members in a chat. Returns Int on success.
*/
public function getChatMembersCount(array $params = []): Response
{
$body = $this->send('/getChatMembersCount', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->getChatMember([
* 'chat_id' => '3343545121', //Unique identifier for the target chat or
* //username of the target supergroup or channel (in the format @channelusername)
* 'user_id' => 243243,//Unique identifier of the target user
* ]);
* Use this method to get information about a member of a chat.
*/
public function getChatMember(array $params = []): Response
{
$body = $this->send('/getChatMember', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->answerCallbackQuery([
* 'callback_query_id' => '3343545121', //require
* 'text' => 'text', //Optional
* 'show_alert' => 'my alert', //Optional
* 'url' => 'http://sample.com', //Optional
* 'cache_time' => 123231, //Optional
* ]);
* Use this method to send answers to callback queries sent from inline keyboards.
* The answer will be displayed to the user as a notification at the top of the chat screen or as an alert.
* On success, True is returned.
*/
public function answerCallbackQuery(array $params = []): Response
{
$body = $this->send('/answerCallbackQuery', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->editMessageText([
* 'chat_id' => '3343545121', //Optional
* 'message_id' => 13123, //Optional
* 'inline_message_id' => 'my alert', //Optional
* 'text' => 'my text', //require
* 'parse_mode' => 123231, //Optional
* 'disable_web_page_preview' => false or true, //Optional
* 'reply_markup' => Type InlineKeyboardMarkup, //Optional
* ]);
* Use this method to edit text and game messages sent by the bot or via the bot (for inline bots). On success,
* if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
*/
public function editMessageText(array $params = []): Response
{
$body = $this->send('/editMessageText', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->editMessageText([
* 'chat_id' => '3343545121', //Required
* 'message_id' => 13123, //Optional
* 'inline_message_id' => 'my alert', //Optional
* 'caption' => 'my text', //require
* 'reply_markup' => Type InlineKeyboardMarkup, //Optional
* ]);
*
* Use this method to edit captions of messages sent by the bot or via the bot (for inline bots). On success,
* if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
*/
public function editMessageCaption(array $params = []): Response
{
$body = $this->send('/editMessageCaption', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->sendGame([
* 'chat_id' => '3343545121', //Required
* 'game_short_name' => 'myGame', //Required
* 'disable_notification' => true, //true or false Optional
* 'reply_to_message_id' => 123121, //Optional
* 'reply_markup' => Type InlineKeyboardMarkup, //Optional
* ]);
*
* Use this method to send a game. On success, the sent Message is returned.
*/
public function sendGame(array $params = []): Response
{
$body = $this->send('/sendGame', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->Game([
* 'title' => 'Title of the game', //Required
* 'description' => 'String', //Required
* 'photo' => Array of PhotoSize, //Photo that will be displayed in the game message in chats
* 'text' => 'String', //Optional
* 'text_entities' => Array of MessageEntity, //Optional
* 'animation' => instance of Animation, //Optional
* ]);
*
* Use this method to send a game. On success, the sent Message is returned.
*/
public function Game(array $params = []): Response
{
$body = $this->send('/Game', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->Animation([
* 'chat_id' => String, //Required
* 'animation' => InputFile or String, //Optional
* 'duration' => Integer, //Optional
* 'width' => Integer, //Optional,
* 'height' => Integer,
* 'thumb' => InputFile or String,
* 'caption' => String,
* 'parse_mode' => String,
* 'disable_notification' => Boolean,
* 'reply_to_message_id' => Integer
* 'reply_markup' => InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply
* ]);
*
* You can provide an animation for your game so that it looks stylish
* in chats (check out Lumberjack for an example). This object represents an animation file to
* be displayed in the message containing a game.
*/
public function sendAnimation(array $params = []): Response
{
$body = $this->send('/sendAnimation', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->CallbackGame([
* 'user_id' => Integer, //Required
* 'score' => Integer, //Required
* 'force' => Boolean, //Optional
* 'disable_edit_message' => Boolean, //Optional
* 'chat_id' => Integer, //Integer
* 'message_id' => Integer, //Optional
* 'inline_message_id' => String, //Optional
* ]);
*
* Use this method to set the score of the specified user in a game. On success,
* if the message was sent by the bot, returns the edited Message, otherwise returns True.
* Returns an error, if the new score is not greater than the user's current score in the chat and force is False.
*/
public function CallbackGame(array $params = []): Response
{
$body = $this->send('/CallbackGame', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->getGameHighScores([
* 'user_id' => Integer, //Required
* 'chat_id' => Integer, //Optional
* 'message_id' => Integer, //Optional
* 'inline_message_id' => String, //Optional
* ]);
*
* Use this method to get data for high score tables.
* Will return the score of the specified user and several of his neighbors in a game.
* On success, returns an Array of GameHighScore objects.
*/
public function getGameHighScores(array $params = []): Response
{
$body = $this->send('/getGameHighScores', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->GameHighScore([
* 'position' => Integer, //Required-Position in high score table for the game
* 'user' => User, //Optional
* 'score' => Integer, //Optional
* ]);
*
* This object represents one row of the high scores table for a game.
*/
public function GameHighScore(array $params = []): Response
{
$body = $this->send('/GameHighScore', $params);
return new Response($body);
}
//----------------------begin inline method--------------------------//
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->answerInlineQuery([
* 'inline_query_id' => Integer, //Required-Position in high score table for the game
* 'user' => User, //Optional
* 'score' => Integer, //Optional
* ]);
*
* This object represents one row of the high scores table for a game.
*/
public function answerInlineQuery(array $params = []): Response
{
$body = $this->send('/answerInlineQuery', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->inlineQuery([
* 'id' => Integer, //Unique identifier for this query
* 'from' => User, //Sender
* 'location' => Location, //Optional. Sender location, only for bots that request user location
* 'query' => String, //Text of the query (up to 256 characters)
* 'offset' => String, //Offset of the results to be returned, can be controlled by the bot
* ]);
*
* This object represents one row of the high scores table for a game.
*/
public function inlineQuery(array $params = []): Response
{
$body = $this->send('/inlineQuery', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->kickChatMember([
* 'chat_id' => Integer, //Unique identifier for the target group or username of the target supergroup or channel
* 'user_id' => Integer, //Unique identifier of the target user
* 'until_date' => Integer, //Date when the user will be unbanned, unix time.
* //If user is banned for more than 366 days or less than 30 seconds from the
* //current time they are considered to be banned forever
* ]);
*
* This object represents one row of the high scores table for a game.
*/
public function kickChatMember(array $params = []): Response
{
$body = $this->send('/kickChatMember', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->unbanChatMember([
* 'chat_id' => Integer, //Unique identifier for the target group or username of the target supergroup or channel
* 'user_id' => Integer, //Unique identifier of the target user
* ]);
*
*/
public function unbanChatMember(array $params = []): Response
{
$body = $this->send('/unbanChatMember', $params);
return new Response($body);
}
/**
* @throws GuzzleException
* @var array
* sample
* Yii::$app->telegram->restrictChatMember([
* 'chat_id' => Integer, //Unique identifier for the target group or username of the target supergroup or * //channel
* 'user_id' => Integer, //Unique identifier of the target user
* 'until_date' => Integer, //Date when the user will be unbanned, unix time.
* //If user is banned for more than 366 days or less than 30 seconds from the
* //current time they are considered to be banned forever
* 'can_send_messages' => Boolean //Pass True, if the user can send text messages,
* //contacts, locations and venues
* ]);
*
* Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for * this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift * restrictions from a user. Returns True on success.
*/
public function restrictChatMember(array $params = []): Response
{
$body = $this->send('/restrictChatMember', $params);
return new Response($body);
}
/**
* @throws GuzzleException
*/
public function promoteChatMember(array $params = []): Response
{
$body = $this->send('/promoteChatMember', $params);
return new Response($body);
}
/**
* @throws GuzzleException
*/
public function exportChatInviteLink(array $params = []): Response
{
$body = $this->send('/exportChatInviteLink', $params);
return new Response($body);
}
/**
* @throws GuzzleException
*/
public function deleteMessage(array $params = []): Response
{
$body = $this->send('/deleteMessage', $params);
return new Response($body);
}
/**
* @throws GuzzleException
*/
public function deleteChatPhoto(array $params = []): Response
{
$body = $this->send('/deleteChatPhoto', $params);
return new Response($body);
}
/**
* @throws GuzzleException
*/
public function setChatTitle(array $params = []): Response
{
$body = $this->send('/setChatTitle', $params);
return new Response($body);
}
/**
* @throws GuzzleException
*/
public function setChatDescription(array $params = []): Response
{
$body = $this->send('/setChatDescription', $params);
return new Response($body);
}
/**
* @throws GuzzleException
*/
public function unpinChatMessage(array $params = []): Response
{
$body = $this->send('/unpinChatMessage', $params);
return new Response($body);
}
/**
* @throws GuzzleException
*/
public function pinChatMessage(array $params = []): Response
{
$body = $this->send('/pinChatMessage', $params);
return new Response($body);
}
/**
* @throws GuzzleException
*/
public function leaveChat(array $params = []): Response
{
$body = $this->send('/leaveChat', $params);
return new Response($body);
}
/**
* @throws GuzzleException
*/
public function setChatStickerSet(array $params = []): Response
{
$body = $this->send('/setChatStickerSet', $params);
return new Response($body);
}
/**
* @throws GuzzleException
*/
public function deleteChatStickerSet(array $params = []): Response
{
$body = $this->send('/deleteChatStickerSet', $params);
return new Response($body);
}
/**
* Yii::$app->telegram->getFile([
* 'file_id' => $file_id
* ]);
*
* @throws GuzzleException
*/
public function getFile($params)
{
return $this->send('/getFile', $params);
}
/**
* Yii::$app->telegram->getFileUrl([
* 'file_id' => $file_id
* ]);
*
* Return file url by file_id
* @throws GuzzleException
*/
public function getFileUrl($params)
{
$body = json_decode(json_encode($this->send('/getFile', $params)), false);
if (isset($body->result, $body->result->file_path) && $body->ok) {
return 'https://api.telegram.org/file/bot' . $this->botToken . '/' . $body->result->file_path;
}
return false;
}
/**
* @throws GuzzleException
*/
public function sendMediaGroup($params)
{
return $this->send('/sendMediaGroup', $params);
}
}