mIRC Home    About    Download    Register    News    Help

Print Thread
Sunday 00 hours... #232400 03/06/11 12:42 AM
Joined: Sep 2007
Posts: 109
K
kwell Offline OP
Vogon poet
OP Offline
Vogon poet
K
Joined: Sep 2007
Posts: 109
I want my bot run every Sunday at 00 a command

Code:
on *:connect: { timercheck 0 60 check }
alias check { 
  if $day = Sunday && $asctime(HH:nn) = 00:00 { command } 
}


It is a good option?

Re: Sunday 00 hours... [Re: kwell] #232401 03/06/11 01:01 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You could just set the timer to trigger at 0:00 and then you only have to check the day.


Invision Support
#Invision on irc.irchighway.net
Re: Sunday 00 hours... [Re: Riamus2] #232405 03/06/11 01:17 AM
Joined: Sep 2007
Posts: 109
K
kwell Offline OP
Vogon poet
OP Offline
Vogon poet
K
Joined: Sep 2007
Posts: 109
Thanks Riamus2

Re: Sunday 00 hours... [Re: kwell] #232406 03/06/11 01:18 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
This should work - at least if you're not staying connected for more than 1 sunday smile
Just to play safe, and to reduce the (unnoticeable, just cosmetical) overhead of checking every minute, you could do something like:

Code:
on *:start: midnight.check

; offline timer that triggers once at midnight
alias midnight.check { timermidnight -o 0:00 1 0 midnight }

alias midnight { 
  if ($day == sunday) { <yourcommand(s)> }
  ; timer to restart the main timer at 0:01 (so it won't re-fire as it's still 0:00)
  timer -o 1 60 midnight.check
}


Edit: Just to add to Riamus2, note that a timer like "timerX 0:00 0 0 <stuff>" would "spam" in a loop, thus the above construct.

Re: Sunday 00 hours... [Re: Horstl] #232407 03/06/11 05:04 AM
Joined: Apr 2010
Posts: 966
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 966
Why not set a timer to go off on the next sunday, then every 7days @ midnight?

Code:
on *:start:{

  ;the $calc() figures out how many seconds left until the next sunday
  .timer:Midnight-Check -oi 1 $calc(604800 - $ctime % 604800) Midnight:Command
}

alias -l Midnight:Command {

;since this triggered on sunday 604800seconds from now is the next sunday's midnight
  .timer:Midnight-Check -oi 0 604800 Midnight:Command 


  ;do stuff here
}

Last edited by FroggieDaFrog; 03/06/11 05:13 AM.

I am SReject
My Stuff
Re: Sunday 00 hours... [Re: FroggieDaFrog] #232410 03/06/11 10:11 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Personally, I'd stick to using a timer set to the time rather than using seconds whenever you want a timer to go off at a specific time.


Invision Support
#Invision on irc.irchighway.net
Re: Sunday 00 hours... [Re: FroggieDaFrog] #232412 03/06/11 11:16 AM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Using timers like that won't account for hour changes or any other adjustments that may me made to the system clock after the timer is set.

Also, mIRC's timers aren't entirely accurate. For intervals in the range of a couple of hours that's fine, over the course of a week it could be noticeable. I'm not sure if the inaccuracy from each week would tend to drift in either direction effectively limiting the size of the error or whether it would be cumulative and get very wrong very quick, but in any case there's a good chance it won't be triggering right on midnight each week.

Using the timer's built-in time parameter is a lot simpler and will eliminate these problems.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: Sunday 00 hours... [Re: Horstl] #232435 05/06/11 02:43 PM
Joined: Sep 2007
Posts: 109
K
kwell Offline OP
Vogon poet
OP Offline
Vogon poet
K
Joined: Sep 2007
Posts: 109
was activated 2 times, the code works great, just change the line timer -o 1 60 midnight.check by timer -o 1 61 midnight.check

thank you very much Horstl