| View previous topic :: View next topic |
| Author |
Message |
billip Voice
Joined: 13 Nov 2005 Posts: 3
|
Posted: Sun Nov 13, 2005 1:30 am Post subject: utimer help please |
|
|
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: |
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 |
|
| Back to top |
|
 |
ryal Voice
Joined: 12 May 2005 Posts: 35
|
Posted: Mon Nov 14, 2005 5:28 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
billip Voice
Joined: 13 Nov 2005 Posts: 3
|
Posted: Mon Nov 14, 2005 2:31 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
]Kami[ Owner

Joined: 24 Jul 2003 Posts: 590 Location: Slovenia
|
Posted: Mon Nov 14, 2005 3:31 pm Post subject: |
|
|
| Code: | 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. _________________ Slovene Eggdrop Page |
|
| Back to top |
|
 |
billip Voice
Joined: 13 Nov 2005 Posts: 3
|
Posted: Mon Nov 14, 2005 3:34 pm Post subject: |
|
|
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! |
|
| Back to top |
|
 |
|