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 

Avoid dupplication of timer

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
neoclust
Halfop


Joined: 14 Aug 2009
Posts: 55

PostPosted: Sun Aug 16, 2009 2:09 pm    Post subject: Avoid dupplication of timer Reply with quote

I want to apply a method to avoid duplication of timers, thanks

Code:
proc Channel:check {from kw text} {
   global botnick
   set chan [lindex $text 1]
   set host [lindex $text 2]@[lindex $text 3]
   set nick [lindex $text 5]
   set flag [lindex $text 6]
   if {[string index $flag 1] == ""} {
      if {![channel get $chan autovoice]} { return 0 }
      if {![botisop $chan]} { return 0 }
      if {$nick != $botnick} {
         if {[string length [set t [utimerexists procname]]]} { killutimer $t }
         if {![string match ~* $host ]} {
            puthelp "NOTICE $nick :Welcome."
            utimer 10 "pushmode $chan +v $nick"
         }
         switch -glob -- $host {*.dynamic.jazztel.es
            {puthelp "NOTICE $nick :Welcome."; utimer 10 "pushmode $chan +v $nick" }
            ~*@* { puthelp "NOTICE $nick :Welcome."; utimer 30 "pushmode $chan +v $nick" }
         }
         return 0                                                                                                                                                                                                     }
   }
}
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun Aug 16, 2009 2:20 pm    Post subject: Reply with quote

Code:
proc Channel:check {from kw text} {
   global botnick vtimers
   set chan [lindex $text 1]
   set host [lindex $text 2]@[lindex $text 3]
   set nick [lindex $text 5]
   set flag [lindex $text 6]
   if {[string index $flag 1] == ""} {
      if {![channel get $chan autovoice]} { return 0 }
      if {![botisop $chan]} { return 0 }
      if {$nick != $botnick} {
         if {[string length [set t [utimerexists procname]]]} { killutimer $t }
         if {![string match ~* $host ] && ![info exists vtimers($nick:$chan)} {
            puthelp "NOTICE $nick :Welcome."
            set vtimers($nick:$chan) [utimer 10 [list voice:nick $chan $nick]]
         }
         switch -glob -- $host {*.dynamic.jazztel.es
            {puthelp "NOTICE $nick :Welcome."; utimer 10 "pushmode $chan +v $nick" }
            ~*@* { puthelp "NOTICE $nick :Welcome."; utimer 30 "pushmode $chan +v $nick" }
         }
         return 0                                                                                                                                                                                                     }
   }
}

proc voice:nick {chan nick} {
 global vtimers
 pushmode $chan +v $nick
 unset vtimers($nick:$chan)
}

_________________
Follow me on GitHub

- Opposing

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


Joined: 14 Aug 2009
Posts: 55

PostPosted: Sun Aug 16, 2009 2:38 pm    Post subject: Reply with quote

There is an ']' missing in this line:
Quote:
if {![string match ~* $host ] && ![info exists vtimers($nick:$chan)]} {

and it must also apply this line
Quote:
set vtimers($nick:$chan) [utimer 10 [list voice:nick $chan $nick]]
in switch

Code:
proc Channel:check {from kw text} {
   global botnick vtimers
   set chan [lindex $text 1]
   set host [lindex $text 2]@[lindex $text 3]
   set nick [lindex $text 5]
   set flag [lindex $text 6]
   if {[string index $flag 1] == ""} {
      if {![channel get $chan autovoice]} { return 0 }
      if {![botisop $chan]} { return 0 }
      if {$nick != $botnick} {
         if {[string length [set t [utimerexists Channel:check]]]} { killutimer $t }
         if {![string match ~* $host ] && ![info exists vtimers($nick:$chan)]} {
            puthelp "NOTICE $nick :Welcome."
            set vtimers($nick:$chan) [utimer 10 [list voice:nick $chan $nick]]
         }
         switch -glob -- $host {*.dynamic.jazztel.es
            {puthelp "NOTICE $nick :Welcome."; set vtimers($nick:$chan) [utimer 10 [list voice:nick $chan $nick]] }
            ~*@* { puthelp "NOTICE $nick :Welcome."; set vtimers($nick:$chan) [utimer 30 [list voice:nick $chan $nick]] }
         }
         return 0                                                                                                                                                                                                     }
   }
}

proc voice:nick {chan nick} {
 global vtimers
 pushmode $chan +v $nick
 unset vtimers($nick:$chan)
}



Last edited by neoclust on Sun Aug 16, 2009 2:57 pm; edited 1 time in total
Back to top
View user's profile Send private message
neoclust
Halfop


Joined: 14 Aug 2009
Posts: 55

PostPosted: Sun Aug 16, 2009 2:45 pm    Post subject: Reply with quote

the bot sends several notice before voice, there is a way to limit this set, for example at the beginning if the nick is already handled by the timer it must pass a return 0
and i have this error :
Quote:
can't unset "vtimers(neoclust:#chan)": no such variable


Quote:
[19:40:00] -Egg- Welcome.
[19:40:12] -Egg- Welcome.
[19:40:26] *** Egg sets mode: +v neoclust
[19:40:29] -Egg- Welcome.
[/quote]
Back to top
View user's profile Send private message
TCL_no_TK
Owner


Joined: 25 Aug 2006
Posts: 509
Location: England, Yorkshire

PostPosted: Mon Aug 17, 2009 4:56 am    Post subject: Reply with quote

sud only allow the bot to send out the "Welcome" message to a nickname once a day.

Arrow it looks like this is a raw event, in which case i doubt you'd be wanting to return 1

Code:
 proc Channel:check {from kw text} {
  global botnick
   set chan [lindex $text 1]
   set host [lindex $text 2]@[lindex $text 3]
   set nick [lindex $text 5]
   set flag [lindex $text 6]
    if {[string index $flag 1] == ""} {
      if {![channel get $chan autovoice]} {
       return
      }
       if {![botisop $chan]} {
        return
       }
        if {$nick != $botnick} {
         if {[string length [set t [utimerexists procname]]]} { killutimer $t }
          switch -glob -- $host {
           *.dynamic.jazztel.es {
            Channel:check:welcome $nick
            utimer 10 [list pushmode $chan +v $nick]
           }
           ~*@* {
            Channel:check:welcome $nick
            utimer 30 [list pushmode $chan +v $nick]
           }
           default {
            Channel:check:welcome $nick
            utimer 10 [list pushmode $chan +v $nick]
           }
         }
     return                                                                                                                                                                                                }
    }
 }

 proc Channel:check:welcome {nick} {
  global cc_tmp
   if {![info exists cc_tmp($nick)]} {
    set cc_tmp($nick) [clock seconds]
    puthelp "NOTICE $nick :Welcome"
    return
   } elseif {[string equal [clock scan "yesterday"] $cc_tmp($nick)]} {
    set cc_tmp($nick) [clock seconds]
    puthelp "NOTICE $nick :Welcome"
    return
   } else {
    return
   }
 }

_________________
TCL the misunderstood
Back to top
View user's profile Send private message Send e-mail
neoclust
Halfop


Joined: 14 Aug 2009
Posts: 55

PostPosted: Mon Aug 17, 2009 8:54 am    Post subject: Reply with quote

Thank TCL_no_TK & Sir_Fz it work
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Aug 17, 2009 2:21 pm    Post subject: Reply with quote

You might want to [split $text] before applying [lindex] on it.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
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