This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

bind notc not working[SOLVED]

Help for those learning Tcl or writing their own scripts.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

ztian299 wrote:

Code: Select all

Command bindings:
  TYPE FLGS     COMMAND              HITS BINDING (TCL)
  notc -|-           search                    0    notice:search
This is what I get in telnet..
This shows that your notice binding has not been triggered..
Abit embarrased I did'nt notice this until now, but well, here it goes...
(7) NOTC (stackable)
bind notc <flags> <mask> <proc>
procname <nick> <user@host> <handle> <text> <dest>

Description: dest will be a nickname (the bot's nickname,
obviously) 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.
Module: server
Especially this part: ...mask is matched against the entire notice and can contain wildcards....

Change the binding into something like this:

Code: Select all

bind notc -|- "search *" notice:search
Also change your proc slightly:
Set the site variable like this instead:

Code: Select all

 set site [lindex [split $text] 1]
NML_375
z
ztian299
Halfop
Posts: 59
Joined: Sat Apr 19, 2008 4:57 pm
Location: *.no

Post by ztian299 »

net-type 5 is right, because I'm not on the listed servers.
why do I need to make a fresh conf? this config have been working very well for me in long time with all other scripts.

Any other suggestions for my problem?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

It's not a config-problem, so I'd suggest you leave it as is for now. Focus on getting the binding corrected first (see my previous post).

(if it ain't broken, don't fix it)
NML_375
z
ztian299
Halfop
Posts: 59
Joined: Sat Apr 19, 2008 4:57 pm
Location: *.no

Post by ztian299 »

My fault! didn't read page 2 of this thread! sorry..
Ok, I'll try all your tip now! hope it works
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

nml375 wrote:Abit embarrased I did'nt notice this until now
In deed, we were beating around the bush :lol:
z
ztian299
Halfop
Posts: 59
Joined: Sat Apr 19, 2008 4:57 pm
Location: *.no

Post by ztian299 »

Thanks a lot for helping me out.. after some .rehash and .restart everything works like it should!

But I want the outputs from SELECT query in each line..
like:
<me> /notice bot search egghelp
<bot> http://egghelp.org
<bot> http://forum.egghelp.org

how is this possible?

I've tried with LIMIT 5, but then it shows like this:
<bot> http://egghelp.org http://forum.egghelp.org
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

mysqlsel can output a valid list (using the -list command). With lists, you can use various list-commands, such as foreach:

Code: Select all

foreach line [mysqlsel $db $query -list] {
 puthelp "PRIVMSG $nick :$line"
}
(Written in a quite generic form, you'll have to adapt the parameters for mysqlsel and such)
NML_375
z
ztian299
Halfop
Posts: 59
Joined: Sat Apr 19, 2008 4:57 pm
Location: *.no

Post by ztian299 »

Great, works like a charm!

What should i use to lock people from getting answer from the bot if their not in a specified channel?

like:
<me> /notice bot search site
and bot won't answer until the person is in channel #test
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

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}
# check if nick is on #test
 if {[onchan $nick #test]} {
  set site [lindex [split $text] 0]
  set result [mysqlsel $dbhandling "SELECT url FROM $sqltable WHERE  site='$site' LIMIT 1" -list]
  foreach line $result {
   putserv "PRIVMSG $nick :$result"
  }
 }
}
z
ztian299
Halfop
Posts: 59
Joined: Sat Apr 19, 2008 4:57 pm
Location: *.no

Post by ztian299 »

Thanks a lot for awesome response!
I'm pretty sure this will be the place I will hang around daily to learn and help 8)
z
ztian299
Halfop
Posts: 59
Joined: Sat Apr 19, 2008 4:57 pm
Location: *.no

Post by ztian299 »

When I search for a url is it possible to move the searched url to another table after the output of search is done?
if so, how would that be done?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Execute another query(s) which will make the move, for example:

Code: Select all

foreach url $results {
 # after outputing the url, delete it from Table1 and insert it into Table2
 mysqlexec $dbhandling "DELETE FROM Table1 WHERE URL='$url'"
 mysqlexec $dbhandling "INSERT INTO Table2(URL) VALUES('$url')"
}
z
ztian299
Halfop
Posts: 59
Joined: Sat Apr 19, 2008 4:57 pm
Location: *.no

Post by ztian299 »

Thanks a lot!
Next: I have been reading a little about event scheduler for MySQL..
Because I want a line from the table2 to move back to table1 after 12hours.
Is this something TCL handle or is it MySQL? I'm not sure
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I'm not sure if an event can be scheduled in MySQL, however it can surely be done using Tcl. You can either use timers or time binds.
z
ztian299
Halfop
Posts: 59
Joined: Sat Apr 19, 2008 4:57 pm
Location: *.no

Post by ztian299 »

Hrrm, looks like it won't work like it should
It only insert into column 'site' and leaves column 'url' blank?

Code: Select all

# /notice bot search

proc notice:search {nick uhost handle text {dest ""}} {
global dbhandling sqltable chan2 sqltable2
if {$dest == ""} {set dest $::botnick}

# check if nick is on #chan

if {[onchan $nick $kanal2]} {
set site [lindex [split $text] 1]
set url [lindex [split $text] 2]

# mysql...

set result [mysqlsel $dbhandling "SELECT url FROM $sqltable WHERE site='$site' LIMIT 1" -list]

foreach line $result {
foreach move $result {
 mysqlexec $dbhandling "DELETE FROM $sqltable WHERE url='$url'"
 mysqlexec $dbhandling "INSERT INTO $sqltable2 (site, url) VALUES ('$site', '$url')"
putserv "PRIVMSG $nick :$line"
putlog "$site searched by $nick"
putlog "$site moved $sqltable -> $sqltable2"
   }
  }
 }
}
Post Reply