-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbotstatus.php
54 lines (49 loc) · 1.44 KB
/
botstatus.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
<?php
error_reporting(0);
include 'vendor/autoload.php';
include 'config.php';
use \React\EventLoop\Factory;
use \unreal4u\TelegramAPI\HttpClientRequestHandler;
use unreal4u\TelegramAPI\Telegram\Methods\GetWebhookInfo;
use unreal4u\TelegramAPI\Telegram\Types\WebhookInfo;
use \unreal4u\TelegramAPI\TgLog;
use \unreal4u\TelegramAPI\Telegram\Methods\SetWebhook;
$loop = \React\EventLoop\Factory::create();
$tgLog = new TgLog(TELEGRAM_BOT_KEY, new HttpClientRequestHandler($loop));
if(isset($_POST['dbpwd']))
{
if($_POST['dbpwd'] == ADMIN_PASSWORD)
{
$loop = Factory::create();
$tgLog = new TgLog(TELEGRAM_BOT_KEY, new HttpClientRequestHandler($loop));
$getWebhookInfo = new GetWebhookInfo();
$promise = $tgLog->performApiRequest($getWebhookInfo);
$promise->then(function($response){
echo json_encode($response);
},
function(\Exception $exception){
echo 'Exception ' . get_class($exception) . ' caught, message: ' . $exception->getMessage();
});
$loop->run();
}
else
{
?>
<form method="POST" action="botstatus.php">
<label>Password errata</label>
<input type="password" name="dbpwd" value="<?php echo $_POST['dbpwd']; ?>" />
<input type="submit" name="submit" value="Avvia" />
</form>
<?php
}
}
else
{
?>
<form method="POST" action="botstatus.php">
<input type="password" name="dbpwd" />
<input type="submit" name="submit" value="Avvia" />
</form>
<?php
}
$loop->run();