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.

How to make a script that runs on specified time?

Old posts that have not been replied to for several years.
Locked
F
Freez
Voice
Posts: 10
Joined: Tue Aug 24, 2004 2:01 pm

How to make a script that runs on specified time?

Post by Freez »

Hi!

I would like to excute soms tcl commands at one specified time.

Time = 18:00 > set mode $chan +mi
Time = 00:00 > set mode $chan -mi

But how? I means its with if ($time == 18:00) but i think it don't work.

Tank You!
D
DrN

Re: How to make a script that runs on specified time?

Post by DrN »

Freez wrote: I would like to excute soms tcl commands at one specified time.
Time = 18:00 > set mode $chan +mi
Time = 00:00 > set mode $chan -mi
bind time - "00 * * * *" timed_modes
proc timed_modes {min hour day month year} {
if {$hour == 18} {pushmode #channel +mi}
if {$hour == 00} {pushmode #channel -mi}
}

Belive that should do what ya want.
F
Freez
Voice
Posts: 10
Joined: Tue Aug 24, 2004 2:01 pm

Post by Freez »

I have try also with minutes, but i don't work. What do i have made wrong?

Code: Select all

bind time - "* * * * *" timed_modes 
proc timed_modes {min hour day month year} { 
if {$hour == 18 && $min == 20} { pushmode $tgchan -mi }
if {$hour == 00} { pushmode $tgchan +mi }
} 
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

seems like you forgot to declare $tgchan
F
Freez
Voice
Posts: 10
Joined: Tue Aug 24, 2004 2:01 pm

Post by Freez »

I have this but it don't work... something wrong?

Code: Select all

set tgchan "#triviant"

bind time - "* * * * *" timed_modes 
proc timed_modes {min hour day month year} { 
if {$hour == 18 && $min == 30} { pushmode $tgchan -mi }
if {$hour == 00} { pushmode $tgchan +mi }
} 
Update: [18:30] Tcl error [timed_modes]: can't read "tgchan": no such variable

He can't read the variable but i have specified...
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

You forgot to add it to the proc.

Code: Select all

set tgchan "#triviant"

bind time - "* * * * *" timed_modes
proc timed_modes {min hour day month year} {
global tgchan
if {$hour == 18 && $min == 30} { pushmode $tgchan -mi }
if {$hour == 00} { pushmode $tgchan +mi }
} 
F
Freez
Voice
Posts: 10
Joined: Tue Aug 24, 2004 2:01 pm

Post by Freez »

It works! I would to like to know how i callup an procedure.

But how?

Code: Select all

proc tgstop {nick host hand chan text} {
	global tghinttimer tgnextqtimer tgplaying tgchan tgcurrentanswer tgstreak tgstreakmin
	global tgerrremindtimer tgrebindhinttimer
	if {[strlwr $tgchan]==[strlwr $chan]} {
		if {$tgplaying==1} {
			tggamemsg "[tgcolstop]Triviant is gestopt door $nick!"
			if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend }
			set tgstreak 0
			set tgplaying 0
			catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
			if {[utimerexists tghint]!=""} {killutimer $tghinttimer}
			if {[utimerexists tgnextq]!=""} {killutimer $tgnextqtimer}
			if {[timerexists tgerrremind]!=""} {killtimer $tgerrremindtimer}
			if {[utimerexists tgrebindhinttimer]!=""} {killtimer $tgrebindhinttimer}
		}
	}
}
This is the proc i want to callup. Do you know how? Thank you!
[/code]
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

This will bind it to the public trigger !stop and everyone is able to use it.

Code: Select all

bind pub -|- !stop tgstop
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Freez wrote:It works! I would to like to know how i callup an procedure.

But how?

Code: Select all

proc tgstop {nick host hand chan text} {
	global tghinttimer tgnextqtimer tgplaying tgchan tgcurrentanswer tgstreak tgstreakmin
	global tgerrremindtimer tgrebindhinttimer
	if {[strlwr $tgchan]==[strlwr $chan]} {
		if {$tgplaying==1} {
			tggamemsg "[tgcolstop]Triviant is gestopt door $nick!"
			if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend }
			set tgstreak 0
			set tgplaying 0
			catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
			if {[utimerexists tghint]!=""} {killutimer $tghinttimer}
			if {[utimerexists tgnextq]!=""} {killutimer $tgnextqtimer}
			if {[timerexists tgerrremind]!=""} {killtimer $tgerrremindtimer}
			if {[utimerexists tgrebindhinttimer]!=""} {killtimer $tgrebindhinttimer}
		}
	}
}
This is the proc i want to callup. Do you know how? Thank you!
[/code]
To callup another procedure from an existing/running procedure use:
procedure:name arg1 arg2 arg3....argN

#You will need to set the same number of arguments as in your call procedure when you are calling.
#If you want to use a bit of delay to call, you can use timers with 'list'

utimer $myutimer [list procedure:name arg1 arg2 arg3....argN]

To call your procedure use:
tgstop $nick $host $hand $chan $text

But remember nick, host, hand, chan and text all have to be defined.
Hope this helps! :wink:
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
F
Freez
Voice
Posts: 10
Joined: Tue Aug 24, 2004 2:01 pm

Post by Freez »

Thank you! It works good!

Do someone know how i can check the day? Not the date!
Like this:

Code: Select all

if ($day == Sunday) then proc
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

The "day" passed from a time bind is the day of month, so there's no way to easily convert it into day of week. 'clock format' to the rescue...

Code: Select all

if {[clock format [clock seconds] -format %u]==7} {it's sunday}
http://tcl.tk/man/tcl8.5/TclCmd/clock.htm#M36
Have you ever read "The Manual"?
Locked