-
Notifications
You must be signed in to change notification settings - Fork 13
/
webhook.php
49 lines (36 loc) · 1.56 KB
/
webhook.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
<?php
require realpath(__DIR__) . '/includes.php';
TelegramBot\Telegram::limit_access_to_telegram_only();
if (empty($_GET['token']) || $_GET['token'] != TOKEN) {
die('Error. The token is invalid.');
}
$db = get_db();
$tg = new TelegramBot\Telegram(TOKEN, TG_ERROR_REPORTING_CHAT_ID);
$tg->setTimeout(30);
$insert_update_to_db = new InsertUpdateToDb($db);
$update = $tg->parseUpdate();
set_language_by_user_id($tg->update_from);
if (!empty($update['message'])) {
if (!empty($update['message']['from'])) {
$insert_update_to_db->insertUser($update['message']['from']);
}
if (!empty($update['message']['chat'])) {
$insert_update_to_db->insertChat($update['message']['chat']);
}
require realpath(__DIR__) . '/update/message/index.php';
} elseif (!empty($update['inline_query'])) {
if (!empty($update['inline_query']['from'])) {
$insert_update_to_db->insertUser($update['inline_query']['from']);
}
require realpath(__DIR__) . '/update/inline_query/index.php';
} elseif (!empty($update['chosen_inline_result'])) {
if (!empty($update['chosen_inline_result']['from'])) {
$insert_update_to_db->insertUser($update['callback_query']['from']);
}
require realpath(__DIR__) . '/update/chosen_inline_result/index.php';
} elseif (!empty($update['callback_query'])) {
if (!empty($update['callback_query']['from'])) {
$insert_update_to_db->insertUser($update['callback_query']['from']);
}
require realpath(__DIR__) . '/update/callback_query/index.php';
}