-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathirc.php
More file actions
executable file
·181 lines (153 loc) · 5.3 KB
/
irc.php
File metadata and controls
executable file
·181 lines (153 loc) · 5.3 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
//Configure
$host = "ircnode.com";
$port = 6667;
$nick = "l0g-d00d";
$chan = "#sethlandia";
$path = './logs/irc.txt';
$admins = array("seth", "ksha", "p0fk", "S[e]C"); //los que pueden tirarle el comando log
$loging = true; //loguea apenas empieza?
//----------------------
include_once('Net/SmartIRC.php');
class logbot
{
//Prender o apagar el logueo
function log_cmd(&$irc, &$data)
{
global $loging, $admins;
if (in_array($data->nick,$admins))
{
$loging = ! $loging;
if ($loging)
{
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel,
'Yes sir! echelon mode ON');
}
else
{
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel,
'Yes sir! echelon mode OFF');
}
}
}
//Muestra si esta logueando
function log_status(&$irc, &$data)
{
global $loging;
if ($loging)
{
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel,
'Echelon mode ON');
}
else
{
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel,
'Echelon mode OFF');
}
}
//Guarda en $fileopen todo lo que pasa en $chan
function log_save(&$irc, &$data)
{
global $loging, $fileopen, $chan;
if ($data->type == SMARTIRC_TYPE_JOIN)
{
fwrite($fileopen, '*'.$data->nick.'* entra a '.$chan."\n");
}
elseif ($data->type == SMARTIRC_TYPE_PART)
{
fwrite($fileopen, '*'.$data->nick.'* sale de '.$chan.' ('.$data->message.")\n");
}
elseif ($data->type == SMARTIRC_TYPE_CHANNEL)
{
fwrite($fileopen, '<'.$data->nick.'> '.$data->message."\n");
}
elseif ($data->type == SMARTIRC_TYPE_NOTICE)
{
fwrite($fileopen, '>'.$data->nick.'< '.$data->message."\n");
}
elseif ($data->type == SMARTIRC_TYPE_TOPICCHANGE)
{
fwrite($fileopen, '*'.$data->nick.'* cambió el topic de '.$data->channel.' a '.$data->message."\n");
}
elseif ($data->type == SMARTIRC_TYPE_TOPIC)
{
fwrite($fileopen, 'El topic para '.$data->channel.' es: '.$data->message."\n");
}
elseif ($data->type == SMARTIRC_TYPE_NICKCHANGE)
{
fwrite($fileopen, '*'.$data->nick.'* ahora es conocido como '.$data->message."\n");
}
elseif ($data->type == SMARTIRC_TYPE_NOTICE)
{
fwrite($fileopen, '>'.$data->nick.'< '.$data->message."\n");
}
elseif ($data->type == SMARTIRC_TYPE_QUIT)
{
fwrite($fileopen, '*'.$data->nick.' salió ('.$data->message.")\n");
}
elseif ($data->type == SMARTIRC_TYPE_MODECHANGE)
{
$quienes = "";
foreach ($data->rawmessageex as $id => $quien)
{
if (($id>3) and($data->rawmessageex[$id] != $data->rawmessageex[$id-1]))
{
$quienes.= $quien." ";
}
}
if(str_replace(" ","",$quienes) == "")
{
fwrite($fileopen, '*'.$data->nick.'* establece modo '.$data->rawmessageex[3].' en '.$data->rawmessageex[2]."\n");
}
else
{
fwrite($fileopen, '*'.$data->nick.'* establece modo '.$data->rawmessageex[3].' a '.$quienes.'en '.$data->rawmessageex[2]."\n");
}
}
elseif ($data->type == SMARTIRC_TYPE_KICK)
{
fwrite($fileopen, '*'.$data->nick.'* hecha a '.$data->rawmessageex[3].' de '.$data->rawmessageex[2].' ('.$data->messageex[0].')'."\n");
}
elseif (($data->type == SMARTIRC_TYPE_NAME) and ($data->message != 'End of /NAMES list.'))
{
fwrite($fileopen, 'Usuarios en '.$data->channel.': '.$data->message."\n");
}
/*//Debugging
elseif (
($data->type != SMARTIRC_TYPE_MOTD) and
($data->type != SMARTIRC_TYPE_CTCP_REQUEST) and
($data->type != SMARTIRC_TYPE_CTCP_REPLY)
)
{
print_r($data);
}*/
}
//Esto es solo para tirar un gettopic
function log_head(&$irc, &$data)
{
global $handler_temporal, $fileopen, $chan;
$irc->getTopic($chan);
$irc->unregisterActionid($handler_temporal);
}
}
$fileopen = fopen($path,'a');
$bot = &new logbot( );
$irc = &new Net_SmartIRC( );
$irc->registerActionhandler( SMARTIRC_TYPE_CHANNEL,
'^'.$nick.'\s*log$', $bot, 'log_cmd' );
$handler_temporal = $irc->registerActionhandler( SMARTIRC_TYPE_ALL,
'.*', $bot, 'log_head' );
$irc->registerActionhandler( SMARTIRC_TYPE_ALL,
'.*', $bot, 'log_save' );
$irc->registerActionhandler( SMARTIRC_TYPE_CHANNEL,
'^'.$nick.'\s*status$', $bot, 'log_status' );
$irc->setAutoReconnect(TRUE);
$irc->setAutoRetry(TRUE);
$irc->setCtcpVersion("Log");
$irc->connect( $host, $port );
$irc->login( $nick, 'Logger', 0, $nick );
$irc->join( array( $chan ) );
$irc->listen( );
$irc->disconnect( );
fclose($fileopen);
?>