-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclassTelegramV2.php
443 lines (415 loc) · 17.1 KB
/
classTelegramV2.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
<?php
class TelegramBotV2{
/**
* Token API telegram
* @example https://core.telegram.org/bots/api
*/
function __construct(){
}
/**
* @example (sendMessage,array_Parameters)
*/
protected function Request($Method, array $Parameters = []){
//Code
}
/**
* @param int|null offset
* @param int|null limit
* @param int|null timeout
* @link https://core.telegram.org/bots/api#getupdates
* Use this method to receive incoming updates using long polling (wiki). An Array of Update objects is returned.
* @return Update[]
*/
public function getUpdates($offset = null, $limit = null, $timeout = null){
$data['offset'] = $offset;
$data['limit'] = $limit;
$data['timeout'] = $timeout;
return $this->Request("getUpdates", $data);
}
/**
* @param String url
* @param string certificate
* @link https://core.telegram.org/bots/api#setwebhook
* Use this method to specify a url and receive incoming updates via an outgoing webhook.
* @return Response
*/
public function setWebhook($url, $certificate = null){
$data['url'] = $url;
$data['certificate'] = $certificate;
return $this->Request("setWebhook", $data);
}
/**
* @link https://core.telegram.org/bots/api#getme
* A simple method for testing your bot's auth token.
* Returns basic information about the bot in form of a User object.
* @return User
*/
public function getMe(){
return $this->Request('getMe');
}
/**
* @param int|String chat_id
* @param string text
* @param string parse_mode
* @param bool disable_web_page_preview
* @param bool disable_notification
* @param int reply_to_message_id
* @param string reply_markup
* @link https://core.telegram.org/bots/api#sendmessage
* Use this method to send text messages. On success, the sent Message is returned.
* @return Message
*/
public function sendMessage($chat_id, $text, $mode = null, $web_page =true, $notification =false, $reply_message = null, $reply_markup = null){
$data["chat_id"]= $chat_id;
$data["text"]= $text;
$data["parse_mode"] = $mode;
$data["disable_web_page_preview"] = $web_page;
$data["disable_notification"] = $notification;
$data["reply_to_message_id"] = $reply_message;
$data["reply_markup"] = $reply_markup;
return $this->Request("sendMessage", $data);
}
/**
* @param int|String chat_id
* @param int from_chat_id
* @param bool disable_notification
* @param bool message_id
* @link https://core.telegram.org/bots/api#forwardmessage
* Use this method to send text messages. On success, the sent Message is returned.
*
* @return Message
*/
public function forwardMessage($chat_id, $from_chat_id, $notification =false, $message_id){
$data["chat_id"] = $chat_id;
$data["from_chat_id"] = $from_chat_id;
$data["disable_notification"] = $notification;
$data["message_id"] = $message_id;
return $this->Request("forwardMessage", $data);
}
/**
* @param int|String chat_id
* @param string photo
* @param string caption
* @param bool disable_notification
* @param int reply_to_message_id
* @param string reply_markup
* @link https://core.telegram.org/bots/api#sendphoto
* Use this method to send photos. On success, the sent Message is returned.
* @return Message
*/
public function sendPhoto($chat_id, $photo, $caption = null, $notification =false, $reply_to_message_id = null, $reply_markup = null){
$data["chat_id"]= $chat_id;
$data["photo"]= $photo;
$data["caption"] = $caption;
$data["disable_notification"] = $notification;
$data["reply_to_message_id"] = $reply_to_message_id;
$data["reply_markup"] = $reply_markup;
return $this->Request("sendPhoto", $data);
}
/**
* @param int|String chat_id
* @param string audio
* @param int duration
* @param string performer
* @param string title
* @param bool disable_notification
* @param int reply_to_message_id
* @param string reply_markup
* @link https://core.telegram.org/bots/api#sendaudio
* can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
* @return Message
*/
public function sendAudio($chat_id, $audio, $duration = null, $performer = null, $title = null, $notification =false, $reply_to_message_id = null, $reply_markup = null){
$data["chat_id"]= $chat_id;
$data["audio"]= $audio;
$data["duration"] = $duration;
$data["performer"] = $performer;
$data["title"] = $title;
$data["disable_notification"] = $notification;
$data["reply_to_message_id"] = $reply_to_message_id;
$data["reply_markup"] = $reply_markup;
return $this->RequestFile("sendAudio", $data);
}
/**
* @param int|String chat_id
* @param string document
* @param string caption
* @param bool disable_notification
* @param int reply_to_message_id
* @param string reply_markup
* @link https://core.telegram.org/bots/api#senddocument
* can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
* @return Message
*/
public function sendDocument($chat_id, $document, $caption = null, $notification =false, $reply_to_message_id = null, $reply_markup = null){
$data["chat_id"]= $chat_id;
$data["document"]= $document;
$data["caption"]= $caption;
$data["disable_notification"] = $notification;
$data["reply_to_message_id"] = $reply_to_message_id;
$data["reply_markup"] = $reply_markup;
return $this->RequestFile("sendDocument", $data);
}
/**
* @param int|String chat_id
* @param string sticker
* @param bool disable_notification
* @param int reply_to_message_id
* @param string reply_markup
* @link https://core.telegram.org/bots/api#sendsticker
* Use this method to send .webp stickers. On success, the sent Message is returned.
* @return Message
*/
public function sendSticker($chat_id, $sticker, $notification =false, $reply_to_message_id = null, $reply_markup = null){
$data["chat_id"]= $chat_id;
$data["sticker"]= $sticker;
$data["disable_notification"] = $notification;
$data["reply_to_message_id"] = $reply_to_message_id;
$data["reply_markup"] = $reply_markup;
return $this->RequestFile("sendSticker", $data);
}
/**
* @param int|String chat_id
* @param string video
* @param int duration
* @param int width
* @param int height
* @param string caption
* @param bool disable_notification
* @param int reply_to_message_id
* @param string reply_markup
* @link https://core.telegram.org/bots/api#sendvideo
* can currently send video files of up to 50 MB in size, this limit may be changed in the future.
* @return Message
*/
public function sendVideo($chat_id, $video, $duration = null, $width =null, $height = mull, $caption = null, $notification =false, $reply_to_message_id = null, $reply_markup = null){
$data["chat_id"]= $chat_id;
$data["video"]= $video;
$data["duration"] = $duration;
$data["width"] = $width;
$data["height"] = $height;
$data["caption"] = $caption;
$data["disable_notification"] = $notification;
$data["reply_to_message_id"] = $reply_to_message_id;
$data["reply_markup"] = $reply_markup;
return $this->RequestFile("sendVideo", $data);
}
/**
* @param int|String chat_id
* @param string voice
* @param int duration
* @param bool disable_notification
* @param int reply_to_message_id
* @param string reply_markup
* @link https://core.telegram.org/bots/api#sendvoice
* can currently send voice files of up to 50 MB in size, this limit may be changed in the future.
* @return Message
*/
public function sendVoice($chat_id, $voice, $duration = null, $notification =false, $reply_to_message_id = null, $reply_markup = null){
$data["chat_id"]= $chat_id;
$data["voice"]= $voice;
$data["duration"] = $duration;
$data["disable_notification"] = $notification;
$data["reply_to_message_id"] = $reply_to_message_id;
$data["reply_markup"] = $reply_markup;
return $this->RequestFile("sendVoice", $data);
}
/**
* @param int|String chat_id
* @param float latitude
* @param float longitude
* @param bool disable_notification
* @param int reply_to_message_id
* @param string reply_markup
* @link https://core.telegram.org/bots/api#sendlocation
* Use this method to send point on the map. On success, the sent Message is returned.
* @return Message
*/
public function sendLocation($chat_id, $latitude, $longitude, $notification =false, $reply_to_message_id = null, $reply_markup = null){
$data["chat_id"]= $chat_id;
$data["latitude"]= $latitude;
$data["longitude"] = $longitude;
$data["disable_notification"] = $notification;
$data["reply_to_message_id"] = $reply_to_message_id;
$data["reply_markup"] = $reply_markup;
return $this->Request("sendLocation", $data);
}
/**
* @param int|String chat_id
* @param float latitude
* @param float longitude
* @param string title
* @param string address
* @param string foursquare_id
* @param bool disable_notification
* @param int reply_to_message_id
* @param string reply_markup
* @link https://core.telegram.org/bots/api#sendvenue
* Use this method to send information about a venue. On success, the sent Message is returned.
* @return Message
*/
public function sendVenue($chat_id, $latitude, $longitude, $title, $address, $foursquare =null, $notification =false, $reply_to_message_id = null, $reply_markup = null){
$data["chat_id"]= $chat_id;
$data["latitude"]= $latitude;
$data["longitude"] = $longitude;
$data["title"] = $title;
$data["address"] = $address;
$data["foursquare_id"] = $foursquare;
$data["disable_notification"] = $notification;
$data["reply_to_message_id"] = $reply_to_message_id;
$data["reply_markup"] = $reply_markup;
return $this->Request("sendVenue", $data);
}
/**
* @param int|String chat_id
* @param string phone_number
* @param string first_name
* @param string last_name
* @param bool disable_notification
* @param int reply_to_message_id
* @param string reply_markup
* @link https://core.telegram.org/bots/api#sendcontact
* Use this method to send phone contacts. On success, the sent Message is returned.
* @return Message
*/
public function sendContact($chat_id, $phone_number, $first_name, $last_name =null, $notification =false, $reply_to_message_id = null, $reply_markup = null){
$data["chat_id"]= $chat_id;
$data["phone_number"]= $phone_number;
$data["first_name"] = $first_name;
$data["last_name"] = $last_name;
$data["disable_notification"] = $notification;
$data["reply_to_message_id"] = $reply_to_message_id;
$data["reply_markup"] = $reply_markup;
return $this->Request("sendContact", $data);
}
/**
* @param int|String chat_id
* @param string action
* @link https://core.telegram.org/bots/api#sendchataction
* Use this method when you need to tell the user that something is happening on the bot's side.
* @return Response
*/
public function sendChatAction($chat_id, $action){
$data["chat_id"]= $chat_id;
$data["action"]= $action; // typing,upload_photo,record_video,upload_video,record_audio,upload_audio,upload_document,find_location
return $this->Request("sendChatAction", $data);
}
/**
* @param int user_id
* @param int offset
* @param int limit
* @link https://core.telegram.org/bots/api#getuserprofilephotos
* Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
* @return User Profile Photos
*/
public function getUserProfilePhotos($user_id, $offset = null, $limit = null){
$data["user_id"]= $user_id;
$data['offset'] = $offset;
$data['limit'] = $limit;
return $this->Request("getUserProfilePhotos", $data);
}
/**
* @param int chat_id
* @param int user_id
* @link https://core.telegram.org/bots/api#kickchatmember
* Use this method to kick a user from a group or a supergroup.
* @return Response
*/
public function kickChatMember($chat_id, $user_id){
$data["chat_id"]= $chat_id;
$data["user_id"]= $user_id;
return $this->Request("kickChatMember", $data);
}
/**
* @param int chat_id
* @param int user_id
* @link https://core.telegram.org/bots/api#unbanchatmember
* Use this method to unban a previously kicked user in a supergroup.
* @return Response
*/
public function unbanChatMember($chat_id, $user_id){
$data["chat_id"]= $chat_id;
$data["user_id"]= $user_id;
return $this->Request("unbanChatMember", $data);
}
/**
* @param String callback_query_id
* @param String text
* @param bool show_alert
* @link https://core.telegram.org/bots/api#answercallbackquery
* Use this method to send answers to callback queries sent from inline keyboards.
* @return Response
*/
public function answerCallbackQuery($callback, $text =null, $alert =false){
$data["callback_query_id"]= $callback;
$data["text"]= $text;
$data["show_alert"]= $alert;
return $this->Request("answerCallbackQuery", $data);
}
/**
* @param int|String chat_id
* @param int message_id
* @param string inline_message_id
* @param string text
* @param string parse_mode
* @param bool disable_web_page_preview
* @param string reply_markup
* @link https://core.telegram.org/bots/api#editmessagetext
* Use this method to edit text messages sent by the bot or via the bot (for inline bots).
* @return Response
*/
public function editMessageText($chat_id, $message_id, $inline_message, $text, $mode = null, $web_page =true, $reply_markup = null){
$data["chat_id"]= $chat_id;
$data["message_id"]= $message_id;
$data["inline_message_id"] = $inline_message;
$data["text"] = $text;
$data["parse_mode"] = $mode;
$data["disable_web_page_preview"] = $web_page;
$data["reply_markup"] = $reply_markup;
return $this->Request("editMessageText", $data);
}
/**
* @param int|String chat_id
* @param int message_id
* @param string inline_message_id
* @param string caption
* @param string reply_markup
* @link https://core.telegram.org/bots/api#editmessagecaption
* Use this method to edit captions of messages sent by the bot or via the bot (for inline bots).
* @return Response
*/
public function editMessageCaption($chat_id, $message_id, $inline_message, $caption = null, $reply_markup = null){
$data["chat_id"]= $chat_id;
$data["message_id"]= $message_id;
$data["inline_message_id"] = $inline_message;
$data["caption"] = $caption;
$data["reply_markup"] = $reply_markup;
return $this->Request("editMessageCaption", $data);
}
/**
* @param int|String chat_id
* @param int message_id
* @param string inline_message_id
* @param string reply_markup
* @link https://core.telegram.org/bots/api#editmessagereplymarkup
* Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
* @return Response
*/
public function editMessageReplyMarkup($chat_id, $message_id, $inline_message, $reply_markup = null){
$data["chat_id"]= $chat_id;
$data["message_id"]= $message_id;
$data["inline_message_id"] = $inline_message;
$data["reply_markup"] = $reply_markup;
return $this->Request("editMessageReplyMarkup", $data);
}
/**
* @param String file_id
* @link https://core.telegram.org/bots/api#getfile
* Use this method to get basic info about a file and prepare it for downloading..
* @return File
*/
public function getFile($file_id){
$data["file_id"]= $file_id;
return $this->Request("getFile", $data);
}
?>