This repository has been archived by the owner on Feb 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
bot.php
102 lines (76 loc) · 2.14 KB
/
bot.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
/* Awesome IRC Bot v2
* Created by AwesomezGuy/Naikcaj/TheAwesomeGuy/Neon/Jackian/Jack Harley
* Yes, I have a lot of names, but I no longer use any but the first 2 online
*
* Copyright (c) 2011, Jack Harley
* All Rights Reserved
*/
require_once(__DIR__ . "/config/config.php");
require_once(__DIR__ . "/lib/awesomeircbot/awesomeircbot.inc.php");
require_once(__DIR__ . "/modules/modules.inc.php");
use config\Config;
use awesomeircbot\server\Server;
use awesomeircbot\module\ModuleManager;
use awesomeircbot\line\ReceivedLine;
use awesomeircbot\line\ReceivedLineTypes;
use awesomeircbot\command\Command;
use awesomeircbot\event\Event;
use awesomeircbot\trigger\Trigger;
use awesomeircbot\database\Database;
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
passthru('clear');
echo "Welcome to Awesome IRC Bot v2\n";
echo "Created by AwesomezGuy, follow @AwesomezGuy on Twitter\n";
if (Config::$die)
die("READ THE CONFIG!\n\n");
if (Config::$configVersion != 4)
die("Your config is out of date, please delete your old config and remake your config from config.example.php\n\n");
ModuleManager::initialize();
$server = Server::getInstance();
$db = Database::getInstance();
$db->updateScriptArrays();
$db->updateDatabase();
echo "\n";
while (true) {
// Connect
$server->connect();
// Identify
$server->identify();
sleep(1);
// NickServ
if (Config::$nickservPassword)
$server->identifyWithNickServ();
// Loop through the channels in the config and join them
foreach(Config::$channels as $channel) {
$server->join($channel);
}
// Loop-edy-loop
$cntUpd = 0;
while($server->connected()) {
$line = $server->getNextLine();
$line = new ReceivedLine($line);
$line->parse();
if ($line->isCommand()) {
$command = new Command($line);
$command->execute();
}
if ($line->isMappedEvent()) {
$event = new Event($line);
$event->execute();
}
if ($line->isMappedTrigger()) {
$trigger = new Trigger($line);
$trigger->execute();
}
$cntUpd++;
if ($cntUpd> 1000)
{
$db->updateDatabase();
$cntUpd = 0;
}
}
// Disconnected, Give the server 2 seconds before we attempt a reconnect
sleep(2);
}
?>