-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathexample-aSync.php
More file actions
27 lines (23 loc) · 856 Bytes
/
example-aSync.php
File metadata and controls
27 lines (23 loc) · 856 Bytes
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
<?php
require __DIR__ . '/vendor/autoload.php';
use Boting\Boting;
use Boting\Exception;
use Psr\Http\Message\ResponseInterface;
$Bot = new Boting();
$Bot->Async = true;
$Bot->catch(function ($e) {
echo $e;
// $e->getErrorDescription();
// $e->getErrorCode();
});
$Bot->command("/[!.\/]start/m", function ($Update, $Match) use ($Bot) {
$ChatId = $Update["message"]["chat"]["id"];
$Baslangic = microtime(true);
$Bot->sendMessage(["chat_id" => $ChatId, "text" => "Ping!"])->then(
function (ResponseInterface $res) use ($Bot, $ChatId, $Baslangic){
$mid = json_decode($res->getBody(), true)["result"]["message_id"];
$Bot->editMessageText(["chat_id" => $ChatId, "message_id" => $mid, "text" => "Pong!\n" . (microtime(true) - $Baslangic) . "ms"]);
}
);
});
$Bot->handler("some token");