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]
# mysql...
set result [mysqlsel $dbhandling "SELECT url FROM $sqltable WHERE site='$site' LIMIT 1" -list]
foreach url $result {
mysqlexec $dbhandling "DELETE FROM $sqltable WHERE url='$url'"
mysqlexec $dbhandling "INSERT INTO $sqltable2 (site, url) VALUES ('$site', '$url')"
putserv "PRIVMSG $nick :$url"
putlog "$site searched by $nick"
putlog "$site moved $sqltable -> $sqltable2"
}
}
}
timer 10 [list
mysqlexec $dbhandling "DELETE FROM $sqltable2 WHERE url='$url'"
mysqlexec $dbhandling "INSERT INTO $sqltable (site, url, nick) VALUES ('$site', '$url', '$nick')"]
Will not work because timer can't do both(I heard).
I got two options:
-make timer in a proc
-make timer again under DELETE.
What is best? I writed this:
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]
# mysql...
set result [mysqlsel $dbhandling "SELECT url FROM $sqltable WHERE site='$site' LIMIT 1" -list]
foreach url $result {
mysqlexec $dbhandling "DELETE FROM $sqltable WHERE url='$url'"
mysqlexec $dbhandling "INSERT INTO $sqltable2 (site, url) VALUES ('$site', '$url')"
putserv "PRIVMSG $nick :$url"
putlog "$site searched by $nick"
putlog "$site moved $sqltable -> $sqltable2"
}
}
}
This calls sql:insert if it is OUTSIDE any procedure and left in global space, it will be executed once and start the sql:insert procedure You can then place an additional timer calling sql:insert inside the actual sql:insert procedure so that this behavior will keep occuring at regular intervals. Understand?
Last edited by speechles on Sat Apr 26, 2008 2:00 pm, edited 1 time in total.
When I see the code Sir_Fz pasted it answer all my answers.
I'm probably not that good to ask questions!
Thanks for explanation speechles..
I asked how the timer could be executed.. In the answer I was hoping to get this.
I appreciate your guys help, I'm sorry for my bad ass questions
Right, tried to find some doc on throttled but nothing.
I have searched throttled. but didn't find anything about restriction?
because i need search restriction for my script
If {[throttled $id $duration]} {return 0} else {#something}
$id = unique identifier for each individual, you tailor this to your whims
$duration = amount in seconds to ignore the user after their initial request.