|
1 <?php |
|
2 |
|
3 eb_hook('event_raw_message', 'enanobot_log_message($chan, $message);'); |
|
4 |
|
5 function enanobot_log_message(&$chan, &$message) |
|
6 { |
|
7 global $nick; |
|
8 |
|
9 // Log the message |
|
10 $chan_db = mysql_real_escape_string($chan->get_channel_name()); |
|
11 $nick_db = mysql_real_escape_string($message['nick']); |
|
12 $line_db = mysql_real_escape_string($message['message']); |
|
13 $day = date('Y-m-d'); |
|
14 $time = time(); |
|
15 $m_et = false; |
|
16 $sql = false; |
|
17 switch($message['action']) |
|
18 { |
|
19 case 'PRIVMSG': |
|
20 if ( substr($line_db, 0, 5) != '[off]' ) |
|
21 { |
|
22 $sql = "INSERT INTO irclog(channel, day, nick, timestamp, line) VALUES |
|
23 ( '$chan_db', '$day', '$nick_db', '$time', '$line_db' );"; |
|
24 } |
|
25 break; |
|
26 case 'JOIN': |
|
27 $sql = "INSERT INTO irclog(channel, day, nick, timestamp, line) VALUES |
|
28 ( '$chan_db', '$day', '', '$time', '$nick_db has joined $chan_db' );"; |
|
29 break; |
|
30 case 'PART': |
|
31 $sql = "INSERT INTO irclog(channel, day, nick, timestamp, line) VALUES |
|
32 ( '$chan_db', '$day', '', '$time', '$nick_db has left $chan_db' );"; |
|
33 break; |
|
34 case 'MODE': |
|
35 list($mode, $target_nick) = explode(' ', $line_db); |
|
36 if ( $message['nick'] != 'ChanServ' && $target_nick != $nick ) |
|
37 { |
|
38 $sql = "INSERT INTO irclog(channel, day, nick, timestamp, line) VALUES |
|
39 ( '$chan_db', '$day', '', '$time', '$nick_db set mode $mode on $target_nick' );"; |
|
40 } |
|
41 break; |
|
42 } |
|
43 if ( $sql ) |
|
44 { |
|
45 eb_mysql_query($sql); |
|
46 } |
|
47 } |
|
48 |