mIRC Homepage
Posted By: kwell Sunday 00 hours... - 03/06/11 12:42 AM
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?
Posted By: Riamus2 Re: Sunday 00 hours... - 03/06/11 01:01 AM
You could just set the timer to trigger at 0:00 and then you only have to check the day.
Posted By: kwell Re: Sunday 00 hours... - 03/06/11 01:17 AM
Thanks Riamus2
Posted By: Horstl Re: Sunday 00 hours... - 03/06/11 01:18 AM
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.
Posted By: FroggieDaFrog Re: Sunday 00 hours... - 03/06/11 05:04 AM
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
}
Posted By: Riamus2 Re: Sunday 00 hours... - 03/06/11 10:11 AM
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.
Posted By: starbucks_mafia Re: Sunday 00 hours... - 03/06/11 11:16 AM
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.
Posted By: kwell Re: Sunday 00 hours... - 05/06/11 02:43 PM
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
© mIRC Discussion Forums