mIRC Home    About    Download    Register    News    Help

Print Thread
#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?

Joined: Oct 2004
Posts: 8,330
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
Joined: Sep 2007
Posts: 109
K
kwell Offline OP
Vogon poet
OP Offline
Vogon poet
K
Joined: Sep 2007
Posts: 109
Thanks Riamus2

Joined: Nov 2006
Posts: 1,559
H
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.

Joined: Apr 2010
Posts: 966
F
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
Joined: Oct 2004
Posts: 8,330
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
Joined: Dec 2002
Posts: 2,962
S
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.
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


Link Copied to Clipboard