This is the new home of the egghelp.org community forum. this announcement post . Click the X in the top right-corner of this box to dismiss this message. 
Help for those learning Tcl or writing their own scripts.
			
		
				
			
				
								neoclust 							 
						Halfop 			
		Posts:  55 Joined:  Fri Aug 14, 2009 11:03 am 
		
						
					
													
							
						
									
						Post 
					 
								by neoclust  Sun Aug 16, 2009 2:09 pm 
			
			
			
			
			
			I want to apply a method to avoid duplication of timers, thanks
Code: Select all 
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                                                                                                                                                                                                     }
	}
}
 
		 
				
		
		 
	 
				
		
				
			
				
								Sir_Fz 							 
						Revered One 			
		Posts:  3794 Joined:  Sun Apr 27, 2003 3:10 pmLocation:  Lebanon
				Contact: 
				
			 
				
		 
		
						
					
						 
													
							
						
									
						Post 
					 
								by Sir_Fz  Sun Aug 16, 2009 2:20 pm 
			
			
			
			
			
			Code: Select all 
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)
} 
		 
				
		
		 
	 
				
		
				
			
				
								neoclust 							 
						Halfop 			
		Posts:  55 Joined:  Fri Aug 14, 2009 11:03 am 
		
						
					
						 
													
							
						
									
						Post 
					 
								by neoclust  Sun Aug 16, 2009 2:38 pm 
			
			
			
			
			
			There is an ']' missing in this line: 
if {![string match ~* $host ] && ![info exists vtimers($nick:$chan)]} {
and it must also apply this line 
set vtimers($nick:$chan) [utimer 10 [list voice:nick $chan $nick]]
 in switch 
Code: Select all 
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.
									
 
		 
				
		
		 
	 
				
		
				
			
				
								neoclust 							 
						Halfop 			
		Posts:  55 Joined:  Fri Aug 14, 2009 11:03 am 
		
						
					
						 
													
							
						
									
						Post 
					 
								by neoclust  Sun Aug 16, 2009 2:45 pm 
			
			
			
			
			
			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 : 
can't unset "vtimers(neoclust:#chan)": no such variable
[19:40:00] -Egg- Welcome.
[/quote]
 
		 
				
		
		 
	 
				
		
				
			
				
								TCL_no_TK 							 
						Owner 			
		Posts:  509 Joined:  Fri Aug 25, 2006 7:05 pmLocation:  England, Yorkshire 
		
						
					
						 
													
							
						
									
						Post 
					 
								by TCL_no_TK  Mon Aug 17, 2009 4:56 am 
			
			
			
			
			
			sud only allow the bot to send out the "Welcome" message to a 
nickname  once a day.
 
 it looks like this is a raw event, in which case i doubt you'd be wanting to return 1
Code: Select all 
 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
   }
 } 
		 
				
		
		 
	 
				
		
				
			
				
								neoclust 							 
						Halfop 			
		Posts:  55 Joined:  Fri Aug 14, 2009 11:03 am 
		
						
					
						 
													
							
						
									
						Post 
					 
								by neoclust  Mon Aug 17, 2009 8:54 am 
			
			
			
			
			
			Thank TCL_no_TK & Sir_Fz it work
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
				
			
				
								Sir_Fz 							 
						Revered One 			
		Posts:  3794 Joined:  Sun Apr 27, 2003 3:10 pmLocation:  Lebanon
				Contact: 
				
			 
				
		 
		
						
					
						 
													
							
						
									
						Post 
					 
								by Sir_Fz  Mon Aug 17, 2009 2:21 pm 
			
			
			
			
			
			You might want to [split $text] before applying [lindex] on it.