|
1 | 1 | <?php |
2 | | -require __DIR__ . '/vendor/autoload.php'; |
3 | | -use Boting\Boting; |
4 | | - |
5 | | -echo "Started"; |
6 | | -$Main = function ($Bot, $Update) { |
7 | | - if (!empty($Update["inline_query"])) { |
8 | | - $Bir = ["type" => "article", "id" => 0, "title" => "test", "input_message_content" => ["message_text" => "sad"]]; |
9 | | - $Bot->answerInlineQuery(["inline_query_id" => $Update["inline_query"]["id"], "results" => json_encode([$Bir])]); |
10 | | - } elseif (!empty($Update["message"])) { |
11 | | - $Message = $Update["message"]["text"]; |
12 | | - $ChatId = $Update["message"]["chat"]["id"]; |
13 | | - |
14 | | - if ($Message === "/start") { |
15 | | - $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Bot Started..."]) |
16 | | - ->sendMessage(["chat_id" => $ChatId, "text" => "Fully Async"]); |
17 | | - } else if ($Message === "/photo") { |
18 | | - $Bot->sendPhoto(["chat_id" => $ChatId, "photo" => "https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Telegram_2019_Logo.svg/1200px-Telegram_2019_Logo.svg.png"]); |
19 | | - } else if ($Message === "/callback") { |
20 | | - $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Example message for callback query", "reply_markup" => json_encode(["inline_keyboard" => [[["text" => "Click me", "callback_data" => "test"], ["text" => "Don't click me", "callback_data" => "test2"]]]])]); |
21 | | - } else if ($Message === "/keyboard") { |
22 | | - $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Example message for keyboard", "reply_markup" => json_encode(["keyboard" => [[["text" => "Click me"], ["text" => "Don't click me"]]]])]); |
23 | | - } else if ($Message === "Click me") { |
24 | | - $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Thanks for click"]); |
25 | | - } else if ($Message === "Don't click me") { |
26 | | - $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Why clicked?!", "reply_markup" => json_encode(["remove_keyboard" => TRUE])]); |
27 | | - } |
28 | | - |
29 | | - } elseif (!empty($Update["callback_query"])) { |
30 | | - $Data = $Update["callback_query"]["data"]; |
31 | | - if ($Data == "test") { |
32 | | - $Bot->editMessageText(["chat_id" => $Update["callback_query"]["message"]["chat"]["id"], "message_id" => $Update["callback_query"]["message"]["message_id"], "text" => "You clicked button!"]); |
33 | | - } else { |
34 | | - $Bot->answerCallbackQuery(["callback_query_id" => $Update["callback_query"]["id"], "text" => "Unknown callback: " . $Data, "show_alert" => true]); |
35 | | - } |
36 | | - } |
37 | | -}; |
38 | | - |
| 2 | +require __DIR__ . '/vendor/autoload.php'; |
| 3 | +use Boting\Boting; |
39 | 4 |
|
40 | 5 | $Bot = new Boting(); |
41 | | -$Bot->Handler("YOUR BOT TOKEN", $Main); |
| 6 | + |
| 7 | +$Bot->command("/[!.\/]start/m", function ($Update, $Match) use ($Bot) { |
| 8 | + $ChatId = $Update["message"]["chat"]["id"]; |
| 9 | + $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Started bot."]); |
| 10 | +}); |
| 11 | + |
| 12 | +$Bot->command("/\/name ?(.*)/m", function ($Update, $Match) use ($Bot) { |
| 13 | + $ChatId = $Update["message"]["chat"]["id"]; |
| 14 | + $Name = $Match->group(1); |
| 15 | + $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Hello, $Name"]); |
| 16 | +}); |
| 17 | + |
| 18 | +$Bot->command("/\/photo/m", function ($Update, $Match) use ($Bot) { |
| 19 | + $ChatId = $Update["message"]["chat"]["id"]; |
| 20 | + $Bot->sendPhoto(["chat_id" => $ChatId, "photo" => "https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Telegram_2019_Logo.svg/1200px-Telegram_2019_Logo.svg.png"]); |
| 21 | +}); |
| 22 | + |
| 23 | +$Bot->command("/\/callback/m", function ($Update, $Match) use ($Bot) { |
| 24 | + $ChatId = $Update["message"]["chat"]["id"]; |
| 25 | + $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Example message for callback query", "reply_markup" => json_encode(["inline_keyboard" => [[["text" => "Click me", "callback_data" => "test"], ["text" => "Don't click me", "callback_data" => "test2"]]]])]); |
| 26 | +}); |
| 27 | + |
| 28 | +$Bot->command("/\/keyboard/m", function ($Update, $Match) use ($Bot) { |
| 29 | + $ChatId = $Update["message"]["chat"]["id"]; |
| 30 | + $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Example message for keyboard", "reply_markup" => json_encode(["keyboard" => [[["text" => "Click me"], ["text" => "Don't click me"]]]])]); |
| 31 | +}); |
| 32 | + |
| 33 | +$Bot->command("/Click me/m", function ($Update, $Match) use ($Bot) { |
| 34 | + $ChatId = $Update["message"]["chat"]["id"]; |
| 35 | + $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Thanks for click"]); |
| 36 | +}); |
| 37 | + |
| 38 | +$Bot->command("/Don\'t click me/m", function ($Update, $Match) use ($Bot) { |
| 39 | + $ChatId = $Update["message"]["chat"]["id"]; |
| 40 | + $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Why clicked?!", "reply_markup" => json_encode(["remove_keyboard" => TRUE])]); |
| 41 | +}); |
| 42 | + |
| 43 | +$Bot->on("sticker", function ($Update) use ($Bot) { |
| 44 | + $ChatId = $Update["message"]["chat"]["id"]; |
| 45 | + $MId = $Update["message"]["message_id"]; |
| 46 | + $bir = microtime(true); |
| 47 | + $First = $Bot->sendMessage(["chat_id" => $ChatId, "text" => "I don't like stickers."]); |
| 48 | + $Bot->deleteMessage(["chat_id" => $ChatId, "message_id" => $MId]); |
| 49 | + $Bot->editMessageText(["chat_id" => $ChatId, "message_id" => $First["result"]["message_id"], "text" => "Deleted in " . (microtime(true) - $bir) . "seconds"]); |
| 50 | +}); |
| 51 | + |
| 52 | +$Bot->on("photo", function ($Update) use ($Bot) { |
| 53 | + $ChatId = $Update["message"]["chat"]["id"]; |
| 54 | + echo $FileId = $Update["message"]["photo"][2]["file_id"]; |
| 55 | + $Ilk = $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Downloading "]); |
| 56 | + $FileName = $Bot->downloadFile($FileId); |
| 57 | + $Bot->editMessageText(["chat_id" => $ChatId, "message_id" => $Ilk["result"]["message_id"], "text" => "Downloaded file as $FileName"]); |
| 58 | + |
| 59 | +}); |
| 60 | + |
| 61 | +$Bot->answer("inline_query", function ($Update) use ($Bot) { |
| 62 | + $Bir = ["type" => "article", "id" => 0, "title" => "test", "input_message_content" => ["message_text" => "This bot created"]]; |
| 63 | + $Bot->answerInlineQuery(["inline_query_id" => $Update["inline_query"]["id"], "results" => json_encode([$Bir])]); |
| 64 | +}); |
| 65 | + |
| 66 | +$Bot->answer("callback_query", function ($Update) use ($Bot) { |
| 67 | + $Data = $Update["callback_query"]["data"]; |
| 68 | + if ($Data == "test") { |
| 69 | + $Bot->editMessageText(["chat_id" => $Update["callback_query"]["message"]["chat"]["id"], "message_id" => $Update["callback_query"]["message"]["message_id"], "text" => "You clicked button!"]); |
| 70 | + } else { |
| 71 | + $Bot->answerCallbackQuery(["callback_query_id" => $Update["callback_query"]["id"], "text" => "Unknown callback: " . $Data, "show_alert" => true]); |
| 72 | + } |
| 73 | +}); |
| 74 | + |
| 75 | +$Bot->handler("920664706:AAEo8NTV_1q_UP8F93kl3CoeD6CzUgJ7xSo"); |
0 commit comments