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 

bind notc not working[SOLVED]
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Apr 25, 2008 8:51 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
ztian299
Halfop


Joined: 19 Apr 2008
Posts: 59
Location: *.no

PostPosted: Sat Apr 26, 2008 8:18 am    Post subject: Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sat Apr 26, 2008 11:37 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
ztian299
Halfop


Joined: 19 Apr 2008
Posts: 59
Location: *.no

PostPosted: Sat Apr 26, 2008 12:11 pm    Post subject: Reply with quote

Can I ask what command that tells the proc sql:insert to execute those lines?
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sat Apr 26, 2008 1:08 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
ztian299
Halfop


Joined: 19 Apr 2008
Posts: 59
Location: *.no

PostPosted: Sat Apr 26, 2008 1:19 pm    Post subject: Reply with quote

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 Embarassed
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sat Apr 26, 2008 1:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sat Apr 26, 2008 2:00 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
ztian299
Halfop


Joined: 19 Apr 2008
Posts: 59
Location: *.no

PostPosted: Sat Apr 26, 2008 2:06 pm    Post subject: Reply with quote

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


Joined: 19 Apr 2008
Posts: 59
Location: *.no

PostPosted: Sun May 18, 2008 9:29 am    Post subject: Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun May 18, 2008 10:39 am    Post subject: Reply with quote

Search for 'throttled'.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
ztian299
Halfop


Joined: 19 Apr 2008
Posts: 59
Location: *.no

PostPosted: Sun May 18, 2008 2:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sun May 18, 2008 2:51 pm    Post subject: Reply with quote

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
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
Goto page Previous  1, 2, 3
Page 3 of 3

 
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