-
Notifications
You must be signed in to change notification settings - Fork 175
/
Copy pathset-my-commands.php
40 lines (31 loc) �� 1.16 KB
/
set-my-commands.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
<?php
declare(strict_types=1);
include __DIR__ . '/basics.php';
use React\EventLoop\Factory;
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
use unreal4u\TelegramAPI\HttpClientRequestHandler;
use unreal4u\TelegramAPI\Telegram\Methods\SetMyCommands;
use unreal4u\TelegramAPI\Telegram\Types\BotCommand;
use unreal4u\TelegramAPI\Telegram\Types\BotCommandScope;
use unreal4u\TelegramAPI\TgLog;
$loop = Factory::create();
$tgLog = new TgLog(BOT_TOKEN, new HttpClientRequestHandler($loop));
$method = new SetMyCommands();
$command = new BotCommand();
$command->command = 'help';
$command->description = 'description for command help for default scope';
$method->commands[] = $command;
$command = new BotCommand();
$command->command = 'settings';
$command->description = sprintf('%s icon and settings description for default scope', "\u{2764}");
$method->commands[] = $command;
$promise = $tgLog->performApiRequest($method);
$promise->then(
function (TelegramTypes $response) {
var_dump('Commands for default scope were set. Use GetMyCommands() to get list of them.');
},
function (\Exception $e) {
var_dump($e->getTraceAsString());
}
);
$loop->run();