| View previous topic :: View next topic |
| Author |
Message |
DjSlash Voice
Joined: 29 Jul 2009 Posts: 8 Location: Groningen, Netherlands
|
Posted: Tue Aug 31, 2010 5:43 pm Post subject: [SOLVED] Retrieving replies from mysql gives unexpected ... |
|
|
Hi all,
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: |
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"
}
}
|
This is what I have in the database:
| Code: |
mysql> select reply from talkbot where binding = 'test';
+---------------------+
| reply |
+---------------------+
| \001ACTION test\001 |
+---------------------+
1 row in set (0.00 sec)
|
This should make the bot do an action, however this is what I get:
| Code: |
23:41 <@DjSlash> !test
23:41 <@StatsBot> \001ACTION test\001
|
I've been trying all kinds of things, but the result remains the same. Any ideas?
Last edited by DjSlash on Tue Aug 31, 2010 6:00 pm; edited 1 time in total |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Aug 31, 2010 5:53 pm Post subject: |
|
|
You'll need to use the subst command if you'd like the escape-sequences to be substituted properly. Most likely, you'll want to use the -nocommands -novariables options to prevent unintended injections. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
DjSlash Voice
Joined: 29 Jul 2009 Posts: 8 Location: Groningen, Netherlands
|
Posted: Tue Aug 31, 2010 5:59 pm Post subject: |
|
|
ahhh, ofcourse. Thanks NML!
PS, your signature isn't correct  |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Aug 31, 2010 6:10 pm Post subject: |
|
|
Well, my poor linux system had a fatal filesystem/harddrive crash some week ago.. Thus I havn't gotten 'round starting up my idling client yet... _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|