Code :
# Use @ your own risk.
# DO use properly configured flood protection.
# It uses the mysqltcl package @ http://www.xdobry.de/mysqltcl
# this works for freebsd..
#load /usr/local/lib/tcl8.5/mysqltcl/libmysqltcl.so.2
load /usr/lib/tcltk/mysqltcl-3.05/libmysqltcl3.05.so
# channel name is converted to lower case and an md5 hash of it is made..
# why? if anyone knows a better way to handle the weird accented chars problem, lemme know ;-)
set dst([md5 [string tolower #INFO]]) info_table
set dst([md5 [string tolower #INFO.Admin]]) admin_table
set dst([md5 [string tolower #DEV]]) DEV_table
set db_handle [mysqlconnect -host localhost -user xxxxx -password xxxx -db HOSTING]
#die "MySQLEGGLOG: RTFM!"
putlog "MySQLEGGLog v0.5 loaded!"
# bind pubm <flags> <mask> <proc>
# procname <nick> <user@host> <handle> <channel> <text>
bind pubm - * egglog_pubmsg
proc egglog_pubmsg { nick host handle channel text } {
global dst
set channel [string tolower $channel]
if { [info exists dst([md5 $channel])] == 0 } { return 0 }
if { ($handle == "") || ($handle == "*")} {
set handle $nick
}
global db_handle
set sql "INSERT DELAYED INTO $dst([md5 $channel]) VALUES(now(), "
set nick [ mysqlescape $nick ]
append sql "'$nick', "
set host [ mysqlescape $host ]
append sql "'$host', "
set channel [ mysqlescape $channel ]
append sql "'$channel', "
set text [mysqlescape $text]
append sql "'$text', "
append sql "'PRIVMSG', "
append sql "'') "
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "Couldn't execute $sql on the server!"
}
}
# bind notc <flags> <mask> <proc>
# procname <nick> <user@host> <handle> <text> <dest>
bind notc - * egglog_pubnotc
proc egglog_pubnotc { nick host handle text dest } {
global dst
set channel [string tolower $dest]
if { [info exists dst([md5 $channel])] == 0 } { return 0 }
if {($handle == "") || ($handle == "*")} {
set handle $nick
}
global db_handle
set sql "INSERT DELAYED INTO $dst([md5 $channel]) VALUES(now(), "
set nick [ mysqlescape $nick ]
append sql "'$nick', "
set host [ mysqlescape $host ]
append sql "'$host', "
set dest [ mysqlescape $dest ]
append sql "'$dest', "
set text [mysqlescape $text]
append sql "'$text', "
append sql "'NOTICE', "
append sql "'') "
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "Couldn't execute $sql on the server!"
}
}
# bind join <flags> <mask> <proc>
# procname <nick> <user@host> <handle> <channel>
bind join - * egglog_join
proc egglog_join { nick host handle channel } {
global dst
set channel [string tolower $channel]
if { [info exists dst([md5 $channel])] == 0 } { return 0 }
if {($handle == "") || ($handle == "*")} {
set handle $nick
}
global db_handle
set sql "INSERT DELAYED INTO $dst([md5 $channel]) VALUES(now(), "
set nick [ mysqlescape $nick ]
append sql "'$nick', "
set host [ mysqlescape $host ]
append sql "'$host', "
set channel [ mysqlescape $channel ]
append sql "'$channel', "
append sql "'', "
append sql "'JOIN',"
append sql "'') "
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "Couldn't execute $sql on the server!"
}
}
# bind part <flags> <mask> <proc>
# procname <nick> <user@host> <handle> <channel> <msg>
bind part - * egglog_part
proc egglog_part { nick host handle channel msg} {
global dst
set channel [string tolower $channel]
if { [info exists dst([md5 $channel])] == 0 } { return 0 }
if {($handle == "") || ($handle == "*")} {
set handle $nick
}
global db_handle
set sql "INSERT DELAYED INTO $dst([md5 $channel]) VALUES(now(), "
set nick [ mysqlescape $nick ]
append sql "'$nick', "
set host [ mysqlescape $host ]
append sql "'$host', "
set channel [ mysqlescape $channel ]
append sql "'$channel', "
set msg [ mysqlescape $msg ]
append sql "'$msg', "
append sql "'PART',"
append sql "'') "
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "Couldn't execute $sql on the server!"
}
}
# bind sign <flags> <mask> <proc>
# procname <nick> <user@host> <handle> <channel> <reason>
bind sign - * egglog_quit
proc egglog_quit { nick host handle channel msg} {
global dst
set channel [string tolower $channel]
if { [info exists dst([md5 $channel])] == 0 } { return 0 }
if {($handle == "") || ($handle == "*")} {
set handle $nick
}
global db_handle
set sql "INSERT DELAYED INTO $dst([md5 $channel]) VALUES(now(), "
set nick [ mysqlescape $nick ]
append sql "'$nick', "
set host [ mysqlescape $host ]
append sql "'$host', "
set channel [ mysqlescape $channel ]
append sql "'$channel', "
set msg [ mysqlescape $msg ]
append sql "'$msg', "
append sql "'QUIT',"
append sql "'') "
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "Couldn't execute $sql on the server!"
}
}
# bind topc <flags> <mask> <proc>
# procname <nick> <user@host> <handle> <channel> <topic>
bind topc - * egglog_topic
proc egglog_topic { nick host handle channel msg} {
global dst
set channel [string tolower $channel]
if { [info exists dst([md5 $channel])] == 0 } { return 0 }
if {($handle == "") || ($handle == "*")} {
set handle $nick
}
global db_handle
set sql "INSERT DELAYED INTO $dst([md5 $channel]) VALUES(now(), "
set nick [ mysqlescape $nick ]
append sql "'$nick', "
set host [ mysqlescape $host ]
append sql "'$host', "
set channel [ mysqlescape $channel ]
append sql "'$channel', "
set msg [mysqlescape $msg]
append sql "'$msg', "
append sql "'TOPIC',"
append sql "'') "
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "Couldn't execute $sql on the server!"
}
}
# bind kick <flags> <mask> <proc>
# procname <nick> <user@host> <handle> <channel> <target> <reason>
bind kick - * egglog_kick
proc egglog_kick { nick host handle channel target action_data } {
global dst
set channel [string tolower $channel]
if { [info exists dst([md5 $channel])] == 0 } { return 0 }
if {($handle == "") || ($handle == "*")} {
set handle $nick
}
global db_handle
set sql "INSERT DELAYED INTO $dst([md5 $channel]) VALUES(now(), "
set nick [ mysqlescape $nick ]
append sql "'$nick', "
set host [ mysqlescape $host ]
append sql "'$host', "
set channel [ mysqlescape $channel ]
append sql "'$channel', "
set target [ mysqlescape $target ]
append sql "'$target', "
append sql "'KICK',"
set action_data [mysqlescape $action_data ]
append sql "'$action_data') "
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "Couldn't execute $sql on the server!"
}
}
# bind nick <flags> <mask> <proc>
# procname <nick> <user@host> <handle> <channel> <newnick>
bind nick - * egglog_nick
proc egglog_nick { nick host handle channel newnick } {
global dst
set channel [string tolower $channel]
if { [info exists dst([md5 $channel])] == 0 } { return 0 }
if {($handle == "") || ($handle == "*")} {
set handle $nick
}
global db_handle
set sql "INSERT DELAYED INTO $dst([md5 $channel]) VALUES(now(), "
set nick [ mysqlescape $nick ]
append sql "'$nick', "
set host [ mysqlescape $host ]
append sql "'$host', "
set channel [ mysqlescape $channel ]
append sql "'$channel', "
set newnick [ mysqlescape $newnick ]
append sql "'$newnick', "
append sql "'NICK',"
append sql "'') "
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "Couldn't execute $sql on the server!"
}
}
# bind mode <flags> <mask> <proc>
# proc-name <nick> <user@host> <handle> <channel> <mode-change> <victim>
bind mode - * egglog_mode
proc egglog_mode { nick host handle channel modechange victim } {
global dst
set channel [string tolower $channel]
if { [info exists dst([md5 $channel])] == 0 } { return 0 }
if {($handle == "") || ($handle == "*")} {
set handle $nick
}
global db_handle
set sql "INSERT DELAYED INTO $dst([md5 $channel]) VALUES(now(), "
set nick [ mysqlescape $nick ]
append sql "'$nick', "
set host [ mysqlescape $host ]
append sql "'$host', "
set channel [ mysqlescape $channel ]
append sql "'$channel', "
set modechange [ mysqlescape $modechange ]
append sql "'$modechange', "
append sql "'MODE',"
set victim [ mysqlescape $victim ]
append sql "'$victim') "
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "Couldn't execute $sql on the server!"
}
}
# bind ctcp <flags> <keyword> <proc>
# proc-name <nick> <user@host> <handle> <dest> <keyword> <text>
bind ctcp - * egglog_ctcp
proc egglog_ctcp { nick host handle dest keyword text } {
global dst
set channel [string tolower $dest]
if { [info exists dst([md5 $channel])] == 0 } { return 0 }
if {($handle == "") || ($handle == "*")} {
set handle $nick
}
global db_handle
set sql "INSERT DELAYED INTO $dst([md5 $channel]) VALUES(now(), "
set nick [ mysqlescape $nick ]
append sql "'$nick', "
set host [ mysqlescape $host ]
append sql "'$host', "
set dest [ mysqlescape $dest ]
append sql "'$dest', "
set keyword [mysqlescape $keyword]
append sql "'$keyword', "
append sql "'CTCP',"
set text [mysqlescape $text]
append sql "'$text') "
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "Couldn't execute $sql on the server!"
}
}
# bind ctcr <flags> <keyword> <proc>
# proc-name <nick> <user@host> <handle> <dest> <keyword> <text>
bind ctcr - * egglog_ctcpreply
proc egglog_ctcpreply { nick host handle dest keyword text } {
global dst
set channel [string tolower $dest]
if { [info exists dst([md5 $channel])] == 0 } { return 0 }
if {($handle == "") || ($handle == "*")} {
set handle $nick
}
global db_handle
set sql "INSERT DELAYED INTO $dst([md5 $channel]) VALUES(now(), "
set nick [ mysqlescape $nick ]
append sql "'$nick', "
set host [ mysqlescape $host ]
append sql "'$host', "
set dest [ mysqlescape $dest ]
append sql "'$dest', "
set keyword [mysqlescape $keyword]
append sql "'$keyword', "
append sql "'CTCP-REPLY',"
set text [mysqlescape $text]
append sql "'$text') "
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "Couldn't execute $sql on the server!"
}
}
# bind splt <flags> <mask> <proc>
# procname <nick> <user@host> <handle> <channel>
bind splt - * egglog_split
proc egglog_split { nick host handle channel } {
global dst
set channel [string tolower $channel]
if { [info exists dst([md5 $channel])] == 0 } { return 0 }
if {($handle == "") || ($handle == "*")} {
set handle $nick
}
global db_handle
set sql "INSERT DELAYED INTO $dst([md5 $channel]) VALUES(now(), "
set nick [ mysqlescape $nick ]
append sql "'$nick', "
set host [ mysqlescape $host ]
append sql "'$host', "
set channel [ mysqlescape $channel ]
append sql "'$channel', "
append sql "'', "
append sql "'NETSPLIT',"
append sql "'') "
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "Couldn't execute $sql on the server!"
}
}
# bind rejn <flags> <mask> <proc>
# procname <nick> <user@host> <handle> <channel>
bind rejn - * egglog_rejoin
proc egglog_rejoin { nick host handle channel } {
global dst
set channel [string tolower $channel]
if { [info exists dst([md5 $channel])] == 0 } { return 0 }
if {($handle == "") || ($handle == "*")} {
set handle $nick
}
global db_handle
set sql "INSERT DELAYED INTO $dst([md5 $channel]) VALUES(now(), "
set nick [ mysqlescape $nick ]
append sql "'$nick', "
set host [ mysqlescape $host ]
append sql "'$host', "
set channel [ mysqlescape $channel ]
append sql "'$channel', "
append sql "'', "
append sql "'REJOIN',"
append sql "'') "
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "Couldn't execute $sql on the server!"
}
}