tgmethod::make_http_request()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 20
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 3
eloc 17
c 2
b 1
f 0
nc 3
nop 2
dl 0
loc 20
rs 9.4285
1
<?php
2
/**
3
 * @package     Telegram
4
 * @link        https://github.com/smartwf/tgmethod
5
 * @author      Smart <[email protected]>
6
 */
7
class tgmethod
8
{
9
    // Telegram Token
10
    protected $token=null;
11
12
    protected $ch;
13
14
    /**
15
     * initialize Class
16
     * @param string $api_token The token looks something like 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
17
     * @return bool
18
     */
19
    public function  __construct($api_token)
20
    {
21
        $this->token=$api_token;
22
        if (strlen($this->token)==45 && count(explode(':',$this->token))==2){
23
            $this->ch = curl_init();
24
            return true;
25
        }
26
        else
27
            return false;
28
    }
29
30
    /**
31
     * Destruct Class
32
     */
33
    public function __destruct()
34
    {
35
        curl_close($this->ch);
36
    }
37
38
    /**
39
     * Make Http Request
40
     * @param string $method  Mothod for calling
41
     * @param object $datas  Datas for Send to Telegram
42
     * @return object
43
     */
44
    private function make_http_request($method,$datas=null){
45
        $url = "https://api.telegram.org/bot".$this->token."/".$method;
46
        curl_setopt($this->ch,CURLOPT_RETURNTRANSFER,true);
47
        curl_setopt($this->ch,CURLOPT_POSTFIELDS,($datas));
48
        curl_setopt($this->ch,CURLOPT_URL,$url);
49
        $res = curl_exec($this->ch);
50
        if(curl_error($this->ch)){
51
            $r=new \stdClass();
52
            $r->ok=false;
53
            $r->description=curl_error($this->ch);
54
            $r->errno=curl_errno($this->ch);
55
            return $r;
56
        }else{
57
            $res=json_decode($res);
58
            if ($res->ok){
59
                $res=$res->result;
60
                $res->ok=true;
61
            }
62
63
            return $res;
64
        }
65
    }
66
67
68
69
70
71
    /////////////////////////////////////////////////////////////////////
72
73
74
75
76
    /******************************************
77
     *                             *
78
     *       Method functions      *
79
     *                             *
80
     ******************************************/
81
82
83
    /**
84
     * Use this method to specify a url and receive incoming updates via an outgoing webhook
85
     * @param string $url HTTPS url to send updates to. Use an empty string to remove webhook integration
86
     * @param array $allowed_updates List the types of updates you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types
87
     * @param int $max_connections Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100
88
     * @param file $certificate Upload your public key certificate so that the root certificate in use can be checked
89
     * @return object
90
     */
91
    public function setWebhook($url,$allowed_updates=null,$max_connections=null,$certificate=null){
92
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
93
    }
94
95
96
97
    /**
98
     * Use this method to remove webhook integration if you decide to switch back to getUpdates
99
     * @return object
100
     */
101
    public function deleteWebhook(){
102
        return $this->make_http_request(__FUNCTION__);
103
    }
104
105
106
107
    /**
108
     * Use this method to get current webhook status. Requires no parameters
109
     * @return object
110
     */
111
    public function getWebhookInfo(){
112
        return $this->make_http_request(__FUNCTION__);
113
    }
114
115
116
117
    /**
118
     * A simple method for testing your bot's auth token
119
     * @return object
120
     */
121
    public function getme(){
122
        return $this->make_http_request(__FUNCTION__);
123
    }
124
125
126
127
    /**
128
     * Use this method to send text messages
129
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
130
     * @param string $text Text of the message to be sent
131
     * @param int $reply_to_message_id If the message is a reply, ID of the original message
132
     * @param json $reply_markup Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
133
     * @param string $parse_mode Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
134
     * @param bool $disable_web_page_preview Disables link previews for links in this message
135
     * @param bool $disable_notification Sends the message silently. Users will receive a notification with no sound.
136
     * @return object
137
     */
138
    public function sendMessage($chat_id,$text,$reply_to_message_id=null,$parse_mode=null,$disable_web_page_preview=null,$reply_markup=null,$disable_notification=null){
139
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
140
    }
141
142
143
144
    /**
145
     * Use this method to forward messages of any kind
146
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
147
     * @param int|string $from_chat_id Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
148
     * @param int $message_id Message identifier in the chat specified in from_chat_id
149
     * @param bool $disable_notification Sends the message silently. Users will receive a notification with no sound.
150
     * @return object
151
     */
152
    public function forwardMessage($chat_id,$from_chat_id,$message_id,$disable_notification=null){
153
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
154
    }
155
156
157
158
    /**
159
     * Use this method to send photos
160
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
161
     * @param string $photo Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data
162
     * @param string $caption Photo caption (may also be used when resending photos by file_id), 0-200 characters
163
     * @param int $reply_to_message_id If the message is a reply, ID of the original message
164
     * @param json $reply_markup Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
165
     * @param bool $disable_notification Sends the message silently. Users will receive a notification with no sound.
166
     * @return object
167
     */
168
    public function sendPhoto($chat_id,$photo,$caption=null,$reply_to_message_id=null,$reply_markup=null,$disable_notification=null){
169
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
170
    }
171
172
173
174
    /**
175
     * Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format.
176
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
177
     * @param string $audio Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data.
178
     * @param string $caption Audio caption, 0-200 characters
179
     * @param int $reply_to_message_id If the message is a reply, ID of the original message
180
     * @param json $reply_markup Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
181
     * @param string $title Track name
182
     * @param int $duration Duration of the audio in seconds
183
     * @param string $performer Performer
184
     * @param bool $disable_notification Sends the message silently. Users will receive a notification with no sound.
185
     * @return object
186
     */
187
    public function sendAudio($chat_id,$audio,$caption=null,$reply_to_message_id=null,$reply_markup=null,$title=null,$duration=null,$performer=null,$disable_notification=null){
188
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
189
    }
190
191
192
193
    /**
194
     * Use this method to send general files
195
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
196
     * @param string $document File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.
197
     * @param string $caption Document caption (may also be used when resending documents by file_id), 0-200 characters
198
     * @param int $reply_to_message_id If the message is a reply, ID of the original message
199
     * @param json $reply_markup Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
200
     * @param bool $disable_notification Sends the message silently. Users will receive a notification with no sound.
201
     * @return object
202
     */
203
    public function sendDocument($chat_id,$document,$caption=null,$reply_to_message_id=null,$reply_markup=null,$disable_notification=null){
204
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
205
    }
206
207
208
209
    /**
210
     * Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document)
211
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
212
     * @param string $video Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data
213
     * @param string $caption Video caption (may also be used when resending videos by file_id), 0-200 characters
214
     * @param int $reply_to_message_id If the message is a reply, ID of the original message
215
     * @param json $reply_markup Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
216
     * @param int $duration Duration of sent video in seconds
217
     * @param string $width	 Video width
218
     * @param string $height Video height
219
     * @param bool $disable_notification Sends the message silently. Users will receive a notification with no sound.
220
     * @return object
221
     */
222
    public function sendVideo($chat_id,$video,$caption=null,$reply_to_message_id=null,$reply_markup=null,$duration=null,$width=null,$height=null,$disable_notification=null){
223
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
224
    }
225
226
227
228
    /**
229
     * Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document)
230
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
231
     * @param string $voice Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data
232
     * @param string $caption Voice message caption, 0-200 characters
233
     * @param int $reply_to_message_id If the message is a reply, ID of the original message
234
     * @param json $reply_markup Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
235
     * @param int $duration Duration of the voice message in seconds
236
     * @param bool $disable_notification Sends the message silently. Users will receive a notification with no sound.
237
     * @return object
238
     */
239
    public function sendVoice($chat_id,$voice,$caption=null,$reply_to_message_id=null,$reply_markup=null,$duration=null,$disable_notification=null){
240
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
241
    }
242
243
244
245
    /**
246
     * As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages
247
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
248
     * @param string $video_note Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. -- Sending video notes by a URL is currently unsupported --
249
     * @param int $reply_to_message_id If the message is a reply, ID of the original message
250
     * @param json $reply_markup Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
251
     * @param int $duration Duration of sent video in seconds
252
     * @param int $length Video width and height
253
     * @param bool $disable_notification Sends the message silently. Users will receive a notification with no sound.
254
     * @return object
255
     */
256
    public function sendVideoNote($chat_id,$video_note,$reply_to_message_id=null,$reply_markup=null,$duration=null,$length=null,$disable_notification=null){
257
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
258
    }
259
260
261
262
    /**
263
     * Use this method to send a group of photos or videos as an album
264
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
265
     * @param array $media A JSON-serialized array describing photos and videos to be sent, must include 2–10 items
266
     * @param int $reply_to_message_id If the message is a reply, ID of the original message
267
     * @param bool $disable_notification Sends the message silently. Users will receive a notification with no sound.
268
     * @return object
269
     */
270
    public function sendMediaGroup($chat_id,$media,$reply_to_message_id=null,$disable_notification=null){
271
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
272
    }
273
274
275
276
    /**
277
     * Use this method to send point on the map
278
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
279
     * @param float $latitude Latitude of the location
280
     * @param float $longitude Longitude of the location
281
     * @param int $reply_to_message_id If the message is a reply, ID of the original message
282
     * @param json $reply_markup Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
283
     * @param int $live_period Period in seconds for which the location will be updated (see Live Locations, should be between 60 and 86400
284
     * @param bool $disable_notification Sends the message silently. Users will receive a notification with no sound.
285
     * @return object
286
     */
287
    public function sendLocation($chat_id,$latitude,$longitude,$reply_to_message_id=null,$reply_markup=null,$live_period=null,$disable_notification=null){
288
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
289
    }
290
291
292
293
    /**
294
     * Use this method to edit live location messages sent by the bot or via the bot (for inline bots). A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation
295
     * @param int|string $chat_id 	Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
296
     * @param int $message_id Required if inline_message_id is not specified. Identifier of the sent message
297
     * @param string $inline_message_id Required if chat_id and message_id are not specified. Identifier of the inline message
298
     * @param float $latitude Latitude of new location
299
     * @param float $longitude Longitude of new location
300
     * @param json $reply_markup Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
301
     * @return object
302
     */
303
    public function editMessageLiveLocation($chat_id=null,$message_id=null,$inline_message_id=null,$latitude,$longitude,$reply_markup=null){
304
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
305
    }
306
307
308
309
    /**
310
     * Use this method to stop updating a live location message sent by the bot or via the bot (for inline bots) before live_period expires.
311
     * @param int|string $chat_id Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
312
     * @param int $message_id Required if inline_message_id is not specified. Identifier of the sent message
313
     * @param string $inline_message_id Required if chat_id and message_id are not specified. Identifier of the inline message
314
     * @param json $reply_markup Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
315
     * @return object
316
     */
317
    public function stopMessageLiveLocation($chat_id=null,$message_id=null,$inline_message_id=null,$reply_markup=null)
318
    {
319
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
320
    }
321
322
323
324
    /**
325
     * Use this method to send information about a venue.
326
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
327
     * @param float $latitude Latitude of the venue
328
     * @param float $longitude Longitude of the venue
329
     * @param string $title Name of the venue
330
     * @param string $address Address of the venue
331
     * @param int $reply_to_message_id If the message is a reply, ID of the original message
332
     * @param json $reply_markup Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
333
     * @param string $foursquare_id Foursquare identifier of the venue
334
     * @param bool $disable_notification Sends the message silently. Users will receive a notification with no sound.
335
     * @return object
336
     */
337
    public function sendVenue($chat_id,$latitude,$longitude,$title,$address,$reply_to_message_id=null,$reply_markup=null,$foursquare_id=null,$disable_notification=null)
338
    {
339
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
340
    }
341
342
343
344
    /**
345
     * Use this method to send phone contacts
346
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
347
     * @param string $phone_number Contact's phone number
348
     * @param string $first_name Contact's first name
349
     * @param string $last_name Contact's last name
350
     * @param int $reply_to_message_id If the message is a reply, ID of the original message
351
     * @param json $reply_markup Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
352
     * @param bool $disable_notification Sends the message silently. Users will receive a notification with no sound.
353
     * @return object
354
     */
355
    public function sendContact($chat_id,$phone_number,$first_name,$last_name=null,$reply_to_message_id=null,$reply_markup=null,$disable_notification=null)
356
    {
357
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
358
    }
359
360
361
362
    /**
363
     * Use this method when you need to tell the user that something is happening on the bot's side.
364
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
365
     * @param string $action
366
     * @return object
367
     */
368
    public function sendChatAction($chat_id,$action)
369
    {
370
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
371
    }
372
373
374
375
    /**
376
     * Use this method to get a list of profile pictures for a user
377
     * @param int $user_id Unique identifier of the target user
378
     * @param int $limit Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100.
379
     * @param int $offset Sequential number of the first photo to be returned. By default, all photos are returned.
380
     * @return object
381
     */
382
    public function getUserProfilePhotos($user_id,$limit=null,$offset=null)
383
    {
384
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
385
    }
386
387
388
389
    /**
390
     * Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size
391
     * @param string $file_id File identifier to get info about
392
     * @return object
393
     */
394
    public function getFile($file_id)
395
    {
396
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
397
    }
398
399
400
    /**
401
     * Use this method to get File link
402
     * @param string|object $file_path The file path received from the getFile function
403
     * @return string
404
     */
405
    public function getFileLink($file_path)
406
    {
407
        if (is_object($file_path))
408
            $file_path=$file_path->file_path;
409
        return 'https://api.telegram.org/file/bot'.$this->token.'/'.$file_path;
410
    }
411
412
413
414
    /**
415
     * Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first
416
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
417
     * @param int $user_id Unique identifier of the target user
418
     * @param int $until_date 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
419
     * @return object
420
     */
421
    public function kickChatMember($chat_id,$user_id,$until_date=null)
422
    {
423
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
424
    }
425
426
427
428
    /**
429
     * Use this method to unban a previously kicked user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc
430
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
431
     * @param int $user_id Unique identifier of the target user
432
     * @return object
433
     */
434
    public function unbanChatMember($chat_id,$user_id)
435
    {
436
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
437
    }
438
439
440
441
    /**
442
     * 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
443
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
444
     * @param int $user_id Unique identifier of the target user
445
     * @param bool $can_send_messages Pass True, if the user can send text messages, contacts, locations and venues
446
     * @param bool $can_send_media_messages Pass True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages
447
     * @param bool $can_send_other_messages Pass True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages
448
     * @param bool $can_add_web_page_previews Pass True, if the user may add web page previews to their messages, implies can_send_media_messages
449
     * @param int $until_date Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever
450
     * @return object
451
     */
452
    public function restrictChatMember($chat_id,$user_id,$can_send_messages=null,$can_send_media_messages=null,$can_send_other_messages=null,$can_add_web_page_previews=null,$until_date=null)
453
    {
454
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
455
    }
456
457
458
459
    /**
460
     * Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
461
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
462
     * @param int $user_id Unique identifier of the target user
463
     * @param bool $can_post_messages Pass True, if the administrator can create channel posts, channels only
464
     * @param bool $can_edit_messages Pass True, if the administrator can edit messages of other users and can pin messages, channels only
465
     * @param bool $can_delete_messages Pass True, if the administrator can delete messages of other users
466
     * @param bool $can_change_info Pass True, if the administrator can change chat title, photo and other settings
467
     * @param bool $can_pin_messages Pass True, if the administrator can pin messages, supergroups only
468
     * @param bool $can_invite_users Pass True, if the administrator can invite new users to the chat
469
     * @param bool $can_promote_members Pass True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him)
470
     * @param bool $can_restrict_members Pass True, if the administrator can restrict, ban or unban chat members
471
     * @return object
472
     */
473
    public function promoteChatMember($chat_id,$user_id,$can_post_messages=null,$can_edit_messages=null,$can_delete_messages=null,$can_change_info=null,$can_pin_messages=null,$can_invite_users=null,$can_promote_members=null,$can_restrict_members=null)
474
    {
475
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
476
    }
477
478
479
480
    /**
481
     * Use this method to export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
482
     * @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
483
     * @return object
484
     */
485
    public function exportChatInviteLink($chat_id)
486
    {
487
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
488
    }
489
490
491
492
    /**
493
     * Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
494
     * @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
495
     * @param file $photo New chat photo, uploaded using multipart/form-data
496
     * @return object
497
     */
498
    public function setChatPhoto($chat_id,$photo)
499
    {
500
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
501
    }
502
503
504
505
    /**
506
     * Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
507
     * @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
508
     * @return object
509
     */
510
    public function deleteChatPhoto($chat_id)
511
    {
512
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
513
    }
514
515
516
517
    /**
518
     * Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
519
     * @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
520
     * @param string $title New chat title, 1-255 characters
521
     * @return object
522
     */
523
    public function setChatTitle($chat_id,$title)
524
    {
525
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
526
    }
527
528
529
530
    /**
531
     * Use this method to change the description of a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
532
     * @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
533
     * @param string $description New chat description, 0-255 characters
534
     * @return object
535
     */
536
    public function setChatDescription($chat_id,$description)
537
    {
538
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
539
    }
540
541
542
543
    /**
544
     * Use this method to pin a message in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel
545
     * @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
546
     * @param string $message_id Identifier of a message to pin
547
     * @param bool $disable_notification Pass True, if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels
548
     * @return object
549
     */
550
    public function pinChatMessage($chat_id,$message_id,$disable_notification=null)
551
    {
552
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
553
    }
554
555
556
557
    /**
558
     * Use this method to unpin a message in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel
559
     * @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
560
     * @return object
561
     */
562
    public function unpinChatMessage($chat_id)
563
    {
564
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
565
    }
566
567
568
569
    /**
570
     * Use this method for your bot to leave a group, supergroup or channel
571
     * @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
572
     * @return object
573
     */
574
    public function leaveChat($chat_id)
575
    {
576
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
577
    }
578
579
580
581
    /**
582
     * Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.)
583
     * @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
584
     * @return object
585
     */
586
    public function getChat($chat_id)
587
    {
588
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
589
    }
590
591
592
593
    /**
594
     * Use this method to get a list of administrators in a chat
595
     * @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
596
     * @return object
597
     */
598
    public function getChatAdministrators($chat_id)
599
    {
600
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
601
    }
602
603
604
605
    /**
606
     * Use this method to get the number of members in a chat
607
     * @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
608
     * @return object
609
     */
610
    public function getChatMembersCount($chat_id)
611
    {
612
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
613
    }
614
615
616
617
    /**
618
     * Use this method to get information about a member of a chat
619
     * @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
620
     * @param int $user_id Unique identifier of the target user
621
     * @return object
622
     */
623
    public function getChatMember($chat_id,$user_id)
624
    {
625
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
626
    }
627
628
629
630
    /**
631
     * Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
632
     * @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
633
     * @param int $sticker_set_name Name of the sticker set to be set as the group sticker set
634
     * @return object
635
     */
636
    public function setChatStickerSet($chat_id,$sticker_set_name)
637
    {
638
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
639
    }
640
641
642
643
    /**
644
     * Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
645
     * @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
646
     * @return object
647
     */
648
    public function deleteChatStickerSet($chat_id)
649
    {
650
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
651
    }
652
653
654
655
    /**
656
     * Use this method to send answers to callback queries sent from inline keyboards
657
     * @param string $callback_query_id Unique identifier for the query to be answered
658
     * @param string $text Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
659
     * @param bool $show_alert If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
660
     * @param string $url URL that will be opened by the user's client.
661
     * @param int $cache_time The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.
662
     * @return object
663
     */
664
    public function answerCallbackQuery($callback_query_id,$text=null,$show_alert=null,$url=null,$cache_time=null)
665
    {
666
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
667
    }
668
669
670
671
    /**
672
     * Use this method to send answers to an inline query
673
     * @param string $inline_query_id Unique identifier for the answered query
674
     * @param json $results A JSON-serialized array of results for the inline query
675
     * @param int $cache_time The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
676
     * @param bool $is_personal Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
677
     * @param string $next_offset Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes.
678
     * @param string $switch_pm_text If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter
679
     * @param string $switch_pm_parameter Deep-linking parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.
680
     * @return object
681
     */
682
    public function answerInlineQuery($inline_query_id,$results,$cache_time=null,$is_personal=null,$next_offset=null,$switch_pm_text=null,$switch_pm_parameter=null)
683
    {
684
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
685
    }
686
687
688
689
    /**
690
     * Use this method to edit text and game messages sent by the bot or via the bot (for inline bots)
691
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
692
     * @param int $message_id Required if inline_message_id is not specified. Identifier of the sent message
693
     * @param string $inline_message_id Required if chat_id and message_id are not specified. Identifier of the inline message
694
     * @param string $text New text of the message
695
     * @param json $reply_markup Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
696
     * @param string $parse_mode Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
697
     * @param bool $disable_web_page_preview Disables link previews for links in this message
698
     * @return object
699
     */
700
    public function editMessageText($chat_id,$message_id,$text,$inline_message_id=null,$reply_markup=null,$parse_mode=null,$disable_web_page_preview=null)
701
    {
702
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
703
    }
704
705
706
707
    /**
708
     * Use this method to edit captions of messages sent by the bot or via the bot (for inline bots)
709
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
710
     * @param int $message_id Required if inline_message_id is not specified. Identifier of the sent message
711
     * @param string $inline_message_id Required if chat_id and message_id are not specified. Identifier of the inline message
712
     * @param string $caption New caption of the message
713
     * @param json $reply_markup Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
714
     * @return object
715
     */
716
    public function editMessageCaption($chat_id,$message_id,$caption,$inline_message_id=null,$reply_markup=null)
717
    {
718
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
719
    }
720
721
722
723
    /**
724
     * Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots)
725
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
726
     * @param int $message_id Required if inline_message_id is not specified. Identifier of the sent message
727
     * @param json $reply_markup Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
728
     * @param string $inline_message_id Required if chat_id and message_id are not specified. Identifier of the inline message
729
     * @return object
730
     */
731
    public function editMessageReplyMarkup($chat_id,$message_id,$reply_markup,$inline_message_id=null)
732
    {
733
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
734
    }
735
736
737
738
    /**
739
     * Use this method to delete a message
740
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
741
     * @param int $message_id Identifier of the message to delete
742
     * @return object
743
     */
744
    public function deleteMessage($chat_id,$message_id)
745
    {
746
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
747
    }
748
749
750
751
    /**
752
     * Use this method to send .webp stickers
753
     * @param int|string $chat_id  Unique identifier for the target chat or username of the target channel (in the format @channelusername)
754
     * @param string $sticker Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .webp file from the Internet, or upload a new one using multipart/form-data
755
     * @param int $reply_to_message_id If the message is a reply, ID of the original message
756
     * @param json $reply_markup Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
757
     * @param bool $disable_notification Sends the message silently. Users will receive a notification with no sound.
758
     * @return object
759
     */
760
    public function sendSticker($chat_id,$sticker,$reply_to_message_id=null,$reply_markup=null,$disable_notification=null){
761
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
762
    }
763
764
765
766
    /**
767
     * Use this method to get a sticker set
768
     * @param string $name Name of the sticker set
769
     * @return object
770
     */
771
    public function getStickerSet($name){
772
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
773
    }
774
775
776
777
    /**
778
     * Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times)
779
     * @param int $user_id User identifier of sticker file owner
780
     * @param file $png_sticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px
781
     * @return object
782
     */
783
    public function uploadStickerFile($user_id,$png_sticker){
784
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
785
    }
786
787
788
789
    /**
790
     * Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set
791
     * @param int $user_id User identifier of sticker file owner
792
     * @param string $name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals)
793
     * @param string $title Sticker set title, 1-64 characters
794
     * @param file $png_sticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px
795
     * @param string $emojis One or more emoji corresponding to the sticker
796
     * @param bool $contains_masks Pass True, if a set of mask stickers should be created
797
     * @param json $mask_position A JSON-serialized object for position where the mask should be placed on faces
798
     * @return object
799
     */
800
    public function createNewStickerSet($user_id,$name,$title,$png_sticker,$emojis,$contains_masks=null,$mask_position=null){
801
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
802
    }
803
804
805
806
    /**
807
     * Use this method to add a new sticker to a set created by the bot
808
     * @param int $user_id User identifier of sticker file owner
809
     * @param string $name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals)
810
     * @param file $png_sticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px
811
     * @param string $emojis One or more emoji corresponding to the sticker
812
     * @param json $mask_position A JSON-serialized object for position where the mask should be placed on faces
813
     * @return object
814
     */
815
    public function addStickerToSet($user_id,$name,$png_sticker,$emojis,$mask_position=null){
816
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
817
    }
818
819
820
821
    /**
822
     * Use this method to move a sticker in a set created by the bot to a specific position
823
     * @param string $sticker File identifier of the sticker
824
     * @param int $position New sticker position in the set, zero-based
825
     * @return object
826
     */
827
    public function setStickerPositionInSet($sticker,$position){
828
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
829
    }
830
831
832
833
    /**
834
     * Use this method to delete a sticker from a set created by the bot
835
     * @param string $sticker File identifier of the sticker
836
     * @return object
837
     */
838
    public function deleteStickerFromSet($sticker){
839
        return $this->make_http_request(__FUNCTION__,(object) get_defined_vars());
840
    }
841
842
843
}