-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
35 lines (29 loc) · 926 Bytes
/
Copy pathindex.php
File metadata and controls
35 lines (29 loc) · 926 Bytes
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
<?
include "include.php";
try {
if (!isset($_cfg_) || count($_cfg_) == 0) throw new Exception("config.php not found");
$bot = new SlackBot($_cfg_['slack']['token'], $_cfg_['slack']['nickname'], $_cfg_['slack']['imageUrl']);
$channelId = $_REQUEST['channel_id'];
$text = $_REQUEST['text'];
$userName = $_REQUEST['user_name'];
$userId = $_REQUEST['user_id'];
if (isBot($userId)) return;
if (isPrefix($text[0])) {
$arr = explode(" ", $text);
$cmd = strtolower(substr(array_shift($arr), 1));
$msg = implode(" ", $arr);
$result = "";
if (isCommand($cmd)) {
$result = $_cfg_['cmd'][$cmd]($msg);
}
if ($result != "") {
$bot->message($channelId, $result);
}
}
} catch (Exception $e) {
if ($fp = fopen(__ROOT__ . "/tmp/error.txt", "at")) {
fputs($fp, date('Y-m-d H:i:s', time()) . "\t[Error] " . $e->getMessage() . "\n");
fclose($fp);
}
}
?>