This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see 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.
			
		
				
			- 
				
								CP1832							
- Halfop
- Posts: 68
- Joined: Thu Oct 09, 2014 4:03 pm
						
					
													
							
						
									
						Post
					
								by CP1832 » 
			
			
			
			
			
			Hi guys:
I am having issues with a simple code that would repeat a given test a few times once every ten seconds. What I would want to achieve is: 
Code: Select all
<user>!annoy bored
+10 seconds <bot>bored
+10 seconds <bot>bored
+10 seconds <bot>bored
+10 seconds <bot>bored
+10 seconds <bot>bored
I wrote this code:
Code: Select all
bind pub - !annoy annoy
proc annoy {nick host handle chan text} {
  set i 0
  while { $i < 6 } {
        utimer 10 [list talk $chan $text]
  	incr i
	}
}
proc talk {chan text} {
 putquick "PRIVMSG $chan :$text"
}
But utimer is only waiting to print out the text the first time (I don't know why) and then the text goes as soon as possible. What am I doing wrong?
 
		 
				
		
		 
	 
				
		
				
			- 
				
								CP1832							
- Halfop
- Posts: 68
- Joined: Thu Oct 09, 2014 4:03 pm
						
					
						
		
													
							
						
									
						Post
					
								by CP1832 » 
			
			
			
			
			
			I was given a solution. Here's the code if it helps.
Code: Select all
bind pub - !annoy annoy
proc annoy {nick uhost handle chan text} {
	global i
	if {![info exists i]} {
		set i 0
	}
	if {$i < 6} {
		putserv "privmsg $chan :$text"
		utimer 10 [list annoy $nick $uhost $handle $chan $text]
		incr i
	} else {
		set i 0
	}
return 1
}