-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
69 lines (63 loc) · 1.89 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
require 'vendor/autoload.php';
require 'bootstrap.php';
use PhpSlackBot\Bot;
use pimax\slackbot\StartCommand;
use pimax\slackbot\AllCommand;
use pimax\slackbot\WebdevCommand;
use pimax\slackbot\BusinessCommand;
use pimax\slackbot\CustomerCommand;
use pimax\slackbot\DesignCommand;
use pimax\slackbot\MarketingCommand;
use pimax\slackbot\MobileCommand;
use pimax\slackbot\ServerCommand;
use pimax\slackbot\SoftwareCommand;
use pimax\slackbot\TranslationsCommand;
use pimax\slackbot\WritingCommand;
$app = []; // app
$config = []; // config
if (file_exists(__DIR__.'/config.php')) {
$config = include __DIR__.'/config.php';
}
if (!empty($argv[1]) && file_exists('installed/'.$argv[1].'.php'))
{
$app = include 'installed/'.$argv[1].'.php';
$config['token'] = $app['bot']['bot_access_token'];
}
else
{
echo "Instance #".$argv[1]. " not a found!";
exit;
}
$bot = new Bot();
$bot->setToken($config['token']); // Get your token here https://my.slack.com/services/new/bot
$bot->loadCommand(new StartCommand());
$bot->loadCommand(new AllCommand());
$bot->loadCommand(new WebdevCommand());
$bot->loadCommand(new BusinessCommand());
$bot->loadCommand(new CustomerCommand());
$bot->loadCommand(new DesignCommand());
$bot->loadCommand(new MarketingCommand());
$bot->loadCommand(new MobileCommand());
$bot->loadCommand(new ServerCommand());
$bot->loadCommand(new SoftwareCommand());
$bot->loadCommand(new TranslationsCommand());
$bot->loadCommand(new WritingCommand());
$bot->run();
/**
* Log
*
* @param mixed $data Data
* @param string $title Title
* @return bool
*/
function writeToLog($data, $title = '')
{
$log = "\n------------------------\n";
$log .= date("Y.m.d G:i:s") . "\n";
$log .= (strlen($title) > 0 ? $title : 'DEBUG') . "\n";
$log .= print_r($data, 1);
$log .= "\n------------------------\n";
file_put_contents(__DIR__ . '/imbot.log', $log, FILE_APPEND);
return true;
}