proc racestats.processTorrentAnnounce { nick userhost handle channel text } {
putlog "TA CP1"
global racestats
set stripped [racestats.strip $text]
set splitted [split $stripped]
# Check for name:
set action [lindex $splitted 1]
# Torrent Name to be searched
set torrentName [lindex $splitted 7]
if {$action == "Name:"} then {
putlog "TA CP2"
set query $torrentName
# By default, MySQL text searches are not case sensitive
set result [racestats.mysql_query "SELECT (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(pretime)), reltitle, nukereason, (UNIX_TIMESTAMP(winnertime) - UNIX_TIMESTAMP(pretime)), winner FROM `$racestats(sql_table)` WHERE `reltitle` LIKE '%[mysqlescape $query]%' ORDER BY 1 ASC LIMIT 1;"]
if {[llength $result] == 1} then {