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.

timer

Old posts that have not been replied to for several years.
Locked
o
oFF

Post by oFF »

Let me start by pasteing my small tcl.


set channel "#lamest"

set text1 "msg here"

bind time - "20 * * * *" text1time

proc text1time {n h handle ch te} {
global text1 channel
foreach chan $channel {
putserv "PRIVMSG $chan :$text1"
}
}

My question is, is there a easier way to do the timer, and if not, would that timer work the same as crontab timers? meaning could i do */20 * * * * for a 20 minute timer?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Eggdrops time bind does not work like crontab, which is a shame, as it would same some time.

Howwver, it is simple enough to use Tcl to check if the current min, is divisible by 20.
if {[expr [string trimleft $min] % 20]} { return }
The above code, would not run the script, unless it was 00, 20 or 40 mins past the hour.

In your script, you use "n h handle ch te" in your proc definition. FOr the above line to work, you would need to change the $min in the script, to $n, or change your proc definition, to something more meaningful, like th example used on tcl-commands.doc.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

SOrry, as for your first question.

There are 2 ways of doing timers, the old, and the new.

The old way, was combersome, and gave problems for people new to scripting, as if strings and lists are not handles properly, they can cause exploits in scripts. For more information, see the timer command in tcl-commands.doc

The new way (which you are using), is the easiest method, and will cause less trouble.
Locked