/
index.php
37 lines (30 loc) · 1.1 KB
/
index.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
<?php
// Published under the MIT License, Copyright (c) 2015 Pius Ladenburger
/* Telegram Bot Info */
define('TOKEN', 'TOKE_RECEIVED_FROM_TELEGRAM');
define('NAME', 'BOT_NAME');
define('MAX_CALLS', 7); // maximum calls per hour
/* MySQL Database Info */
define('MYSQL_HOST', 'localhost');
define('MYSQL_USER', 'USERNAME');
define('MYSQL_PASSWORD', 'PASSWORD');
define('MYSQL_NAME', 'BOT');
require './advanced/class.DB.php';
require './advanced/class.session.php';
require './class.telegram.php';
$bot = new Telegram(TOKEN, NAME);
// $DB = new \System\Database\MySQL(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_NAME);
// Incoming update
$request = json_decode(file_get_contents('php://input'), true);
if ($request['update_id']) {
// Message received
// BOT CODE HERE
// API: https://core.telegram.org/bots/api#getting-updates
}
if ($_GET['setHook']) {
// uncomment, type in your webhook domain and visit example.com/path/to/bot/?setHook=1 to register the hook
echo $bot->setWebhook('https://example.com/telegram_bot');
} else {
// uncomment if you need some troubleshooting
// include ('./advanced/debug.php');
}