Repository navigation
Expand file tree
/
Copy pathgetUpdates.php
More file actions
93 lines (79 loc) · 3.54 KB
/
Copy pathgetUpdates.php
File metadata and controls
93 lines (79 loc) · 3.54 KB
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
<?php
// if you move the example in the root of your project, you must change the path of the require_once below
require_once __DIR__ . "/../vendor/autoload.php";
use TuriBot\Client;
use TuriBot\InputFile;
$client = new Client("TOKEN");
$offset = 0;
while (true) {
$updates = $client->getUpdates($offset, $timeout = 0);
if ($updates->ok === true) {
foreach ($updates->result as $update) {
$offset = $update->update_id + 1;
$easy = new \TuriBot\EasyVars($update);
if (isset($update->message)) {
$chat_id = $update->message->chat->id;
if (isset($update->message->reply_to_message->from->id)) {
$reply_id = $update->message->reply_to_message->from->id;
}
if ($easy->text === "ping") {
$client->sendMessage($chat_id, "pong");
} else {
$client->sendMessage($chat_id, $easy->message_id);
}
if ($easy->text === "test") {
$result = $client->sendMessage($chat_id, "test");
$client->debug($chat_id, $result);
}
if ($easy->text === "/photo") {
// you must put a photo file for test it
$client->sendPhoto($chat_id, new InputFile("photo.jpg"));
}
if ($easy->text === "/mute" and isset($reply_id)) {
$perm = [
"can_send_messages" => false
];
$result = $client->restrictChatMember($chat_id, $reply_id, $perm);
$client->debug($chat_id, $result);
}
if ($easy->text === '/editmedia') {
$result_photo = $client->sendPhoto($chat_id,
'https://core.telegram.org/file/811140327/1/zlN4goPTupk/9ff2f2f01c4bd1b013', 'test photo');
if ($result_photo->ok === true) {
$inputMediaPhoto = [
'type' => 'photo',
'media' => $client->inputFile('a.png'),
];
$client->editMessageMedia($inputMediaPhoto, $chat_id, $result_photo->result->message_id);
}
}
if ($easy->text === '/mediagroup') {
$inputMediaPhoto1 = [
'type' => 'photo',
'media' => 'https://core.telegram.org/file/811140327/1/zlN4goPTupk/9ff2f2f01c4bd1b013',
];
$inputMediaPhoto2 = [
'type' => 'photo',
'media' => $client->inputFile('a.png'),
];
$client->sendMediaGroup($chat_id, [$inputMediaPhoto1, $inputMediaPhoto2]);
}
} elseif (isset($update->inline_query)) {
$out = (string)rand();
$results[] = [
"type" => "article",
"id" => $out,
"title" => $out,
"input_message_content" => [
"message_text" => $out,
"disable_web_page_preview" => true
],
];
$client->answerInlineQuery($update->inline_query->id, $results, 1, false);
unset($results);
}
}
} else {
exit($updates->description);
}
}