I'm playing with an idea I have for a while and I'm using the mysql module from BarkerJr for it. I have made a script that makes bindings according to the stuff in the database. Since it is just an experiment, I didn't put much tought to it. However, what's been bugging me for a couple of hours now is that I don't get the expected result from what I have right now.
This is the code:
Code: Select all
proc tb:respond { nick uhost hand chan arg binding} {
global talkbot
mysql_connect $talkbot(db_name) $talkbot(db_host) $talkbot(db_uname) $talkbot(db_pass)
set respond_query "SELECT reply FROM talkbot WHERE binding = '$binding' ORDER BY RAND() LIMIT 1"
set result [mysql_query $respond_query]
if {[mysql_affected_rows] < 1} {
putlog "TalkBot MySQL error: $result ([mysql_errno])"
return 0
} else {
set reply [lindex [lindex $result 0] 0]
putserv "privmsg $chan :$reply"
}
}
Code: Select all
mysql> select reply from talkbot where binding = 'test';
+---------------------+
| reply |
+---------------------+
| \001ACTION test\001 |
+---------------------+
1 row in set (0.00 sec)
Code: Select all
23:41 <@DjSlash> !test
23:41 <@StatsBot> \001ACTION test\001