| View previous topic :: View next topic |
| Author |
Message |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Apr 25, 2008 8:51 pm Post subject: |
|
|
You meant
| Code: | 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"
}
}
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
ztian299 Halfop
Joined: 19 Apr 2008 Posts: 59 Location: *.no
|
Posted: Sat Apr 26, 2008 8:18 am Post subject: |
|
|
I thought it was necessary to use two foreach.
Example:
| Code: |
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:
| Code: |
proc timer:notice {nick uhost handle arg} {
global dbhandling sqltable sqltable2
timer 10 [list mysqlexec $dbhandling "DELETE FROM $sqltable2 WHERE url='$url'"]
putlog "deleted from $sqltable2"
timer 10 [list mysqlexec $dbhandling "INSERT INTO $sqltable (site, url) VALUES ('$site', '$url')"]
putlog "added to $sqltable"
}
|
I'm trying, but don't know if this is working? |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Apr 26, 2008 11:37 am Post subject: |
|
|
It's more optimal to create a new procedure.
| Code: | proc sql:insert {nick site url} {
global dbhandling
mysqlexec $dbhandling "DELETE FROM $sqltable2 WHERE url='$url'"
mysqlexec $dbhandling "INSERT INTO $sqltable (site, url, nick) VALUES ('$site', '$url', '$nick')"
} |
and just call the timer like this
| Code: | | timer 10 [list sql:insert $nick $site $url] |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
ztian299 Halfop
Joined: 19 Apr 2008 Posts: 59 Location: *.no
|
Posted: Sat Apr 26, 2008 12:11 pm Post subject: |
|
|
| Can I ask what command that tells the proc sql:insert to execute those lines? |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Apr 26, 2008 1:08 pm Post subject: |
|
|
| ztian299 wrote: | | Can I ask what command that tells the proc sql:insert to execute those lines? |
What do you meant "what command?" it's called within the timer if that's what you mean. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
ztian299 Halfop
Joined: 19 Apr 2008 Posts: 59 Location: *.no
|
Posted: Sat Apr 26, 2008 1:19 pm Post subject: |
|
|
| Code: |
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"
}
}
}
|
| Code: |
proc sql:insert {nick site url} {
global dbhandling
mysqlexec $dbhandling "DELETE FROM $sqltable2 WHERE url='$url'"
mysqlexec $dbhandling "INSERT INTO $sqltable (site, url, nick) VALUES ('$site', '$url', '$nick')"
timer 1 [list sql:insert $nick $site $url]
putlog "DONE"
}
|
How does proc sql:insert work since not any variables or anything call it?
Sorry about confusing questions. But this part is getting hard  |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sat Apr 26, 2008 1:51 pm Post subject: |
|
|
Your failing to understand how tcl works entirely. | Code: | | timer 1 [list sql:insert $nick $site $url] | 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 |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Apr 26, 2008 2:00 pm Post subject: |
|
|
You're not being clear about what you want, I guess you want this:
| Code: | 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 {
timer 10 [list sql:insert $nick $url $site]
putserv "PRIVMSG $nick :$url"
putlog "$site searched by $nick"
}
}
}
proc sql:insert {nick url site} {
global dbhandling sqltable sqltable2
mysqlexec $dbhandling "DELETE FROM $sqltable WHERE url='$url'"
mysqlexec $dbhandling "INSERT INTO $sqltable2 (site, url, nick) VALUES ('$site', '$url', '$nick')"
putlog "$site moved $sqltable -> $sqltable2"
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
ztian299 Halfop
Joined: 19 Apr 2008 Posts: 59 Location: *.no
|
Posted: Sat Apr 26, 2008 2:06 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
ztian299 Halfop
Joined: 19 Apr 2008 Posts: 59 Location: *.no
|
Posted: Sun May 18, 2008 9:29 am Post subject: |
|
|
I continue.. I need to set how many times people can search, and if exceed ignore for 6hours!
I'm not sure how the "if exceed" would be done. Help appreciated |
|
| 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 May 18, 2008 2:00 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sun May 18, 2008 2:51 pm Post subject: |
|
|
See this thread:
http://forum.egghelp.org/viewtopic.php?t=9009&start=3
Use the new function this creates as I have below:
| Code: | | 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. |
|
| Back to top |
|
 |
|