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.

bind time [SOLVED]

Help for those learning Tcl or writing their own scripts.
Post Reply
c
cache
Master
Posts: 306
Joined: Tue Jan 10, 2006 4:59 am
Location: Mass

bind time [SOLVED]

Post by cache »

Need help with bind time, trying to get the bot to say something every monday and thursday at 9am.

day is a zero padded two digit integer 01 through 31 representing day of the month.

Does this mean I need to make a proc for every month since the days aren't the same for each month? Like the 15th could be monday for one month then next month it could be tuesday. Not an issue if I have to, just wonder if there is a short way?

Thanks
Last edited by cache on Thu Jul 08, 2010 3:07 pm, edited 1 time in total.
w
willyw
Revered One
Posts: 1209
Joined: Thu Jan 15, 2009 12:55 am

Re: bind time

Post by willyw »

cache wrote:Need help with bind time, trying to get the bot to say something every monday and thursday at 9am.

day is a zero padded two digit integer 01 through 31 representing day of the month.

Does this mean I need to make a proc for every month since the days aren't the same for each month? Like the 15th could be monday for one month then next month it could be tuesday. Not an issue if I have to, just wonder if there is a short way?

Thanks
How about using bind time to run a proc every day at 9:00, and within that proc check to see if today is Monday or Thursday?

Something like this:

Code: Select all

bind time - "* 09 * * *" time_demo


proc time_demo {min hour day month year} {

  if {"[strftime %A]"=="Monday"} {
	##  commands to say what you want to say on Monday go here
	}


  if {"[strftime %A]"=="Thursday"} {
	#commands to say what you want to say on Thursday go here
	}

}

References:
http://www.baschny.de/eggdrop/faq/faq-f.html
and find the section on bind time

tcl-commands.doc for strftime command, and also:
http://linux.about.com/library/cmd/blcmdl3_strftime.htm
for a nice list of the formats.

I'm half asleep... I hope I got it right. With some quick testing, as best I could, ... it worked.

I hope this helps.
p
pseudo
Halfop
Posts: 88
Joined: Mon Nov 23, 2009 4:52 am
Location: Bulgaria
Contact:

Post by pseudo »

With the new 1.6.20rc1, you could use bind cron instead of bind time which simplifies the job.

Example: bind cron - "00 09 * * 01,04" your_proc

This will trigger every Monday and Thursday at 9AM.
w
willyw
Revered One
Posts: 1209
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

pseudo wrote:With the new 1.6.20rc1, you could use bind cron instead of bind time which simplifies the job.

Example: bind cron - "00 09 * * 01,04" your_proc

This will trigger every Monday and Thursday at 9AM.
Hey, hey! :D
This is news!
I didn't even know there was a newer version of Eggdrop out. You caused me to go look, and I found it was dated just yesterday.

Reminds me of this thread that I started, some time ago:
http://forum.egghelp.org/viewtopic.php?t=17477

Thank you for mentioning it.
c
cache
Master
Posts: 306
Joined: Tue Jan 10, 2006 4:59 am
Location: Mass

Post by cache »

Thanks, you guys rock! :D
Post Reply