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.

utimer help please

Help for those learning Tcl or writing their own scripts.
Post Reply
b
billip
Voice
Posts: 3
Joined: Sun Nov 13, 2005 1:22 am

utimer help please

Post by billip »

Hi there,

I currently have a script on the bot that pulls a text file from the server and displays the contents to the channel when it hears the trigger command "!info" on the channel.

The problem I'm having is I wish to add a delay in the script but I cant seem to get the Utimer to work.

I want it so someone in the channel types !info then there is a delay which I can specify before the bot forwards the info to the channel.

The error I was getting was: Tcl error [moo]: wrong # args: should be "utimer seconds command"

current code I am using (without the utimer bits) is:

Code: Select all

package require http
bind pub - !info moo
proc moo {n u h c t} {
   set x [::http::geturl http://www.somewebsite.com/test.txt]
   foreach e [split [::http::data $x] \n] {puthelp "privmsg $c :$e"}
::http::cleanup $x
} 
Just wondering if anyone could please help me out and show me where to put the utimer so the code works properly and I can specify a delay before the bot responds.

Any help would be very much appreciated!

-Billip
r
ryal
Voice
Posts: 35
Joined: Thu May 12, 2005 6:10 pm

Post by ryal »

A timer TIMER or UTIMER (difference is that the first works in minutes, the second in seconds) must be used like this:
set mytimer [timer $mytime myaction]
thus if you need to kill it, u use $mytimer to call it
"myaction" is the action taken when the time ends
So basically to do what you want:
*parse the info in the proc moo and store it in a global variable
*at the end of moo set a timer and tell it to call a certain proc "time_to_display" for example
*create time_to_display: make it display the info you have parsed before

Thats it. I quite dont understand why you wanna do that, but thats not of my concern :)
gl
b
billip
Voice
Posts: 3
Joined: Sun Nov 13, 2005 1:22 am

Post by billip »

managed to kill the bot about 10 times but still not managed to get it to work.

I think I understand the theory behind utimers, I just cant figure out how to get it to work with that code.

thanks for the tips though ryal
User avatar
]Kami[
Owner
Posts: 590
Joined: Thu Jul 24, 2003 2:59 pm
Location: Slovenia
Contact:

Post by ]Kami[ »

Code: Select all

package require http
bind pub - !info moo
proc moo {n u h c t} {
   set x [::http::geturl http://www.somewebsite.com/test.txt]
   foreach e [split [::http::data $x] \n] {
   utimer 10 "puthelp \"privmsg $c :$e\""}
::http::cleanup $x
}
Change 10 (seconds) with delay you wind to use.
b
billip
Voice
Posts: 3
Joined: Sun Nov 13, 2005 1:22 am

Post by billip »

thank you kami! and ryal for the hints also.

I tried having the utimer just about everywhere but I never tried it inside those brackets.

cheers for the help!
Post Reply