-
Notifications
You must be signed in to change notification settings - Fork 4
/
getUpdateCLI.php
52 lines (41 loc) · 1.23 KB
/
getUpdateCLI.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
<?php
require __DIR__ . '/vendor/autoload.php';
use Longman\TelegramBot\Request;
use Longman\TelegramBot\Telegram;
use MohandesPlusBot\utils\ConfigProvider\ConfigComponent;
use MohandesPlusBot\utils\DatabaseProvider\Database;
$config = new ConfigComponent();
$botConfig = $config->getBotConfig();
$config = $config->getDatabaseConfig();
$API_KEY = $botConfig['token'];
$BOT_NAME = $botConfig['name'];
$mysql_credentials = [
'host' => "localhost",
'user' => "XXX",
'password' => "XXX",
'database' => "postgram_bot_lib"
];
try
{
// Create Telegram API object
$telegram = new Telegram($API_KEY, $BOT_NAME);
// Enable MySQL
$telegram->enableMySQL($mysql_credentials);
// Handle telegram getUpdate request
$telegram->addCommandsPath('commands');
// $telegram->setLogRequests(true);
// $telegram->setLogPath($BOT_NAME . '.log');
// $telegram->setLogVerbosity(3);
$telegram->setDownloadPath('images');
$postSender = new \MohandesPlusBot\Handler\PostSender();
while (true)
{
$telegram->handleGetUpdates();
$postSender->sendToChannel();
// sleep(5);
}
} catch (Longman\TelegramBot\Exception\TelegramException $e)
{
echo $e->getMessage();
echo $e->getTrace();
}