| View previous topic :: View next topic |
| Author |
Message |
ztian299 Halfop
Joined: 19 Apr 2008 Posts: 59 Location: *.no
|
Posted: Sat Apr 19, 2008 5:06 pm Post subject: bind notc not working[SOLVED] |
|
|
Hello!
I'm trying to make a search to mysql with notice.
/notice bot1 search <site>
This is my own code and I try to learn. Searched google many hours but didn't find it useful so I decided to ask here. Appreciate help
| Code: |
bind notc - search notice:search
set dbhandling [mysqlexec -u root -p test123 -db search]
set sqltable "test"
proc notice:search {nick uhost handle text {dest ""}} {
global dbhandling sqltable
if {$dest == ""} {set dest $::botnick}
set site [lindex $text 0]
set result [mysqlsel $dbhandling "SELECT url FROM $sqltable WHERE site='$site' LIMIT 1" -list]
putserv "PRIVMSG $nick :$result"
}
|
I'm back with this problem, the bot doesn't output anything. No text, no errors[/code]
Last edited by ztian299 on Sun Apr 20, 2008 12:12 pm; edited 3 times in total |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Apr 19, 2008 5:35 pm Post subject: |
|
|
From Tcl-commands.doc:
| Quote: | NOTC (stackable)
bind notc <flags> <mask> <proc>
procname <nick> <user@host> <handle> <text> <dest>
Description: dest will be a nickname (the bot's nickname,
bviously) or a channel name. mask is matched against the entire
notice and can contain wildcards. It is considered a breach of
protocol to respond to a /notice on IRC, so this is intended for
internal use (logging, etc.) only. Note that server notices do
not trigger the NOTC bind. If the proc returns 1, Eggdrop will
not log the message that triggered this bind.
New Tcl procs should be declared as
proc notcproc {nick uhost hand text {dest ""}} {
global botnick; if {$dest == ""} {set dest $botnick}
...
}
for compatibility. |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
ztian299 Halfop
Joined: 19 Apr 2008 Posts: 59 Location: *.no
|
Posted: Sat Apr 19, 2008 5:48 pm Post subject: hi |
|
|
Thanks for reply that fast Sir_Fz,
I have been looking at that one LONG time.. and have tried it but won't work!
here's the code with that!
---------------------------------
set dbhandling [mysqlexec -u root -p test123 -db search]
set sqltable "test"
bind notc - search notice:search
proc notice:search {nick uhost hand arg text {dest ""}} {
global dbhandling sqltable botnick
if {$dest == ""}
{set dest $botnick}
set site [lindex $arg 0]
set result [mysqlsel $dbhandling "SELECT url FROM $sqltable WHERE site='$site' LIMIT 1" -list]
putserv "PRIVMSG $nick :$result"
}
bot doesn't answer, and no error output |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Apr 19, 2008 6:31 pm Post subject: |
|
|
It's:
| Quote: | | procname <nick> <user@host> <handle> <text> <dest> |
Notice what's wrong with your procedure's arguments. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
ztian299 Halfop
Joined: 19 Apr 2008 Posts: 59 Location: *.no
|
Posted: Sat Apr 19, 2008 7:16 pm Post subject: |
|
|
| I'm seriously not sure. Could you give me an example that you could help me better than that one? Appreciate your help! |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Apr 19, 2008 7:41 pm Post subject: |
|
|
What Sir_Fz is trying to tell you is that it should look like this:
| Code: | bind notc - search notice:search
set dbhandling [mysqlexec -u root -p test123 -db search]
set sqltable "test"
proc notice:search {nick uhost handle text {dest ""}} {
global dbhandling sqltable
if {$dest == ""} {set dest $::botnick}
set site [lindex $text 0]
set result [mysqlsel $dbhandling "SELECT url FROM $sqltable WHERE site='$site' LIMIT 1" -list]
putserv "PRIVMSG $nick :$result"
} |
In your first piece of code, you've mixed up the order of the parameters: The arguments you write in your notice-command (/notice search <parameters>) will always be the 4th argument.
Further on, it is a very bad idea to use lindex on strings; especially ones from untrusted sources... Use split to convert it into a list first.
(that is, change "set site [lindex $text 0]" into "set site [lindex [split $text] 0]") _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Apr 20, 2008 2:46 pm Post subject: |
|
|
Looking further, it seems you do not create a valid database-handle. You should use mysqlconnect to connect to the database, not mysqlexec. Hence, your mysqlsel command will never be able to retrieve any data from the database. I would also re-emphasis the last paragraph in my previous post - don't use lindex on strings, take the effort of converting it to a list first.
http://www.xdobry.de/mysqltcl/mysqltcl.html documents all the function calls in the mysqltcl package. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
ztian299 Halfop
Joined: 19 Apr 2008 Posts: 59 Location: *.no
|
Posted: Sun Apr 20, 2008 3:13 pm Post subject: |
|
|
Ah, sorry..
to explain, I don't really use mysqlexec in the connect, I was to tired this morning when i wrote it on this post.. But I use mysqlconnect.
Then as you told, I could use split function with lindex.. I asked on #eggtcl @ EFnet and got the answer "set test [lindex [split $arg] 0]"
I assume you already told me that, but I will try again.
| Code: |
bind notc - search notice:search
set dbhandling [mysqlconnect -u root -p test123 -db search]
set sqltable "test"
proc notice:search {nick uhost handle text {dest ""}} {
global dbhandling sqltable
if {$dest == ""} {set dest $::botnick}
set site [lindex [split $text] 0]
set result [mysqlsel $dbhandling "SELECT url FROM $sqltable WHERE site='$site' LIMIT 1" -list]
putserv "PRIVMSG $nick :$result"
}
|
Still no reply from bot when notice
Appreciate your help. thanks |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
ztian299 Halfop
Joined: 19 Apr 2008 Posts: 59 Location: *.no
|
Posted: Sun Apr 20, 2008 3:26 pm Post subject: |
|
|
I've tried .rehash and .restart
I'm wondering about the notice action if it really works with mysqltcl
because it worked with search in pm, but not with notice. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Apr 20, 2008 3:30 pm Post subject: |
|
|
Could you paste the output of ".binds notc all" after triggering the command a couple of times? _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
ztian299 Halfop
Joined: 19 Apr 2008 Posts: 59 Location: *.no
|
Posted: Sun Apr 20, 2008 3:33 pm Post subject: |
|
|
| Code: |
Command bindings:
TYPE FLGS COMMAND HITS BINDING (TCL)
notc -|- search 0 notice:search
|
This is what I get in telnet.. |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun Apr 20, 2008 4:00 pm Post subject: |
|
|
Are you sure you have the correct net-type setting in your eggdrop.conf? It seems like your bot is not recognizing notices. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
ztian299 Halfop
Joined: 19 Apr 2008 Posts: 59 Location: *.no
|
Posted: Sun Apr 20, 2008 4:19 pm Post subject: |
|
|
Here is my conf: http://pastebin.com/d42679c0
Every time I send a notice to the bot it pop-up in telnet that I try.
But nothing happen |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun Apr 20, 2008 5:54 pm Post subject: |
|
|
You have a custom eggdrop.conf file, I suggest you reconfigure a fresh original copy. However, you have net-type 5 set; is it the correct net-type setting for you? _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
|