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.

timed events

Old posts that have not been replied to for several years.
Locked
S
SomeGuy
Voice
Posts: 13
Joined: Sat May 01, 2004 5:25 pm

timed events

Post by SomeGuy »

I've decided to make a script to alert people when something in a game happens.

The way this work is this, a user will add a date/time like this:
!add May-15@12:00pm Description

Now I have a few questions, first being is how can I convert that date/time to unix format?

My other question is once i've converted it to unix time, how can I get the bot to say something to the channel exactly an hour before that time. So in this case, at 11:00am its gotta message something like "1 Hour till time".

Is this possible? I can handle things if I just figure out these two questions.

Thanks
S
SomeGuy
Voice
Posts: 13
Joined: Sat May 01, 2004 5:25 pm

Post by SomeGuy »

Code: Select all

bind pub - "!time" proc_test_time
proc proc_test_time {nick user hand chan arg} {
  set unix_time [unixtime]
  set current_time [strftime %H:%M]
  set time120 [strftime %H:%M [expr {[clock scan $current_time]+7200}]]
  set time30 [strftime %H:%M [expr {[clock scan $time120]-1800}]]
  set time60 [strftime %H:%M [expr {[clock scan $time30]-3600}]]
  putserv "PRIVMSG $chan :UNIX\: $unix_time  REAL\: $current_time  +2HOURS\: $time120  -30MINS\: $time30  -1HOUR\: $time60"
  return 0
}
OUTPUT:
UNIX: 1085245248 REAL: 11:00 +2HOURS: 13:00 -30MINS: 12:30 -1HOUR: 11:30

I did some playing around and so far I got that working. I'm stuck when it comes to adding a date to it. This only works for HH:MM, preferably, i want users to type in:

!add May-15@13:00

Decided to go 24 hour clock, easier to work with.

So now i'm just down to the one question...
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Use

Code: Select all

bind time - * time:check
proc time:check {min hour args} {
# check in here to see if hour:min is before your time in question
# (or just use the system's time again)
}
the time binding will be called once a minute...
just add code..
Locked