egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[SOLVED] Retrieving replies from mysql gives unexpected ...

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
DjSlash
Voice


Joined: 29 Jul 2009
Posts: 8
Location: Groningen, Netherlands

PostPosted: Tue Aug 31, 2010 5:43 pm    Post subject: [SOLVED] Retrieving replies from mysql gives unexpected ... Reply with quote

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
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Aug 31, 2010 5:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
DjSlash
Voice


Joined: 29 Jul 2009
Posts: 8
Location: Groningen, Netherlands

PostPosted: Tue Aug 31, 2010 5:59 pm    Post subject: Reply with quote

ahhh, ofcourse. Thanks NML!

PS, your signature isn't correct Wink
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Aug 31, 2010 6:10 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber