-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbot.php
More file actions
60 lines (50 loc) · 1.63 KB
/
bot.php
File metadata and controls
60 lines (50 loc) · 1.63 KB
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
55
56
57
58
59
60
<?php
/* Includes */
include 'methods.php';
$config = include 'config.php';
include 'utils.php';
/* Configuraciones */
$bot = new api;
$utils = new utils;
$GLOBALS['website'] = "https://api.telegram.org/bot".$config["token"];
$mysqli = new mysqli($config["mysql"]["host"], $config["mysql"]["user"], $config["mysql"]["password"], $config["mysql"]["database"]);
/*---------------------------*/
$updates = file_get_contents("php://input");
if (!$updates) { return; };
$updates = json_decode($updates, TRUE);
$msg = $updates["message"];
$msg["cb"] = $updates["callback_query"];
if ($mysqli->connect_error) {
if ($config["report_mysql_errors"]) {
$bot->sendMessage($config["owners"][0], "*Error while connecting MySQL*.", "markdown");
};
};
if ($config["var_dump"]) {
$result = $utils->get_vardump($msg);
if ($result) {
$bot->sendMessage($config["owners"][0], $result);
return;
};
};
foreach ($config["plugins"] as $plugin) {
$actual_plugin = include_once "plugins/".$plugin;
$actioned = false;
if (isset($actual_plugin["pre_process"])) {
call_user_func($actual_plugin["pre_process"], $msg);
};
if (isset($actual_plugin["exe"])) {
foreach ($actual_plugin["patterns"] as $pattern) {
preg_match($pattern, $msg["text"], $matches, PREG_OFFSET_CAPTURE);
if ($matches) {
call_user_func($actual_plugin["exe"], $msg, $matches);
$actioned = true;
break;
};
};
};
if ($actioned) { break; };
};
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>