-
Notifications
You must be signed in to change notification settings - Fork 2
/
moderator.php
79 lines (57 loc) · 1.84 KB
/
moderator.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
<?php
/*
Title: Cluck MSN Bot
Developer: Brendan Mc. (Bren2010)
Purpose: Moo on MSN.
Version: 1.0
*/
/*************** CONFIGURATION ***************/
$config = parse_ini_file("config.ini", TRUE);
$nick = $config['nickserv']['nick'];
$registered = $config['nickserv']['registered'];
$password = $config['nickserv']['password'];
$bot = $config['nickserv']['bot'];
$modeLock = str_split($config['nickserv']['modeLock'], 1);
$server = $config['server']['server'];
$port = $config['server']['port'];
$channel = $config['server']['channel'];
// System Settings
$daemon = $config['system']['daemon']; // Run the bot as a daemon.
/******************* CODE ********************/
error_reporting(0);
if ($daemon == TRUE) {
if(pcntl_fork()) die(); // This turns the bot into a daemon.
}
set_time_limit(0); // So PHP never times out
require_once("functions.php");
require_once("modules.php");
require_once("ircMsg.php");
$modules = new modules();
$operators = array();
$reqCommand = "";
$updateInterval = 30;
$nextUpdate = time() + $updateInterval;
$socket = fsockopen($server, $port);
cmd_send("USER " . $nick . " " . $nick . " " . $nick . " : " . $nick); // Register user data.
cmd_send("NICK " . $nick); // Change nick.
cmd_send("JOIN " . $channel); // Join default channel.
while (1) {
while (!feof($socket)) {
$data = fgets($socket);
$pingCheck = substr($data, 0, strlen("PING :"));
if ($pingCheck == "PING :") {
$pong = substr($data, strlen("PING :"));
cmd_send("PONG :" . $pong);
} else {
$message = new ircMsg($data);
$command = strtolower($message->getCommand());
$modules->hook($command, $message);
}
$time = time();
if ($time >= $nextUpdate) {
$modules->hook("periodic", NULL);
$nextUpdate = $time + $updateInterval;
}
}
}
?>