mIRC Homepage

Script to post a message at a certain time

Posted By: wordprodigy

Script to post a message at a certain time - 18/08/20 07:30 PM

How would I go about creating a simple script to echo a twitch message at a certain time? For example at 0900, it would output "Good Morning" in twitch chat.
Posted By: KindOne

Re: Script to post a message at a certain time - 18/08/20 10:43 PM

/timergood_morning 9:00 0 1 msg #channel Good Morning

/help timer

Posted By: cwodavids

Re: Script to post a message at a certain time - 27/08/20 06:08 PM

This is great info, thanks!

Is it possible to take this one step further and have 6 different chats that have 40-50 automated messages in each window at specified times?

The time would have to be in a T + format i.e. T + 1 hr 1 min 24 secs.

I would love to set this up for a training scenario we have that lasts around 2 hrs and would like to have windows scrolling away whilst a person works and tries to process the info.
Posted By: maroon

Re: Script to post a message at a certain time - 28/08/20 03:28 PM

If you had looked at the link in the post to which you replied, you would have seen the answer. You can have timers which trigger in N seconds-from-now rather than a specific time in the future.

If you want them to trigger at specific intervals after a specific time, you would create an alias containing all the timers, and launch them all at the same time either by typing the /name_of_the_alias in the channel's editbox or by launching a timer at a specific timer which executes that alias.

The link about mSL Injection warns against risky behavior with timers. Basically, you should avoid putting text into a timer containing names of identifiers and names of variables, unless you know what you're doing. Especially be careful against including $1- in a timer if that $1- represents a string typed by someone else in a chat message.

//timertest 1 5 echo -a $asctime vs $ $+ asctime vs $unsafe($ $+ asctime) | timertest

This shows you the 3 different ways the above identifier is placed into the timer command. The first one evaluates as you launch the timer, showing the time when you launched it. The 2nd one puts the name of the identifier there causing it to evaluate when the timer executes. The 3rd one shields the name of the identifier so the "$asctime" string displays in the echo, without evaluating at either time.

If you have calculations of timer intervals, it's best to either pass parameters to the alias for it to make calculations using them, or to do the calculation at the time you launch the timer.

//var %delay 123 | timertest 1 %delay echo -a T+ $duration(%delay) message

This launches a timer to execute 123 seconds into the future, and calculates the display now. However, if you use the command "/timertest -e" it will execute the timer early, yet it will still show the original calculation of the T+interval.

//var %delay 123 | timertest 1 %delay echo -a T+ $!duration( $!calc( $!time - $ctime )) message | timertest

Using /timertest -e to execute this one early causes it to show the true interval.

Note that, when you create a timer to execute N seconds in the future, it can trigger in the middle of a minute. But if you provide the seconds when you want the timer to execute at a specific time, the seconds are ignored. The next timer tries to execute at the time that's 60 seconds in the future, but always executes at the beginning of the minute, so it's possible for this command to execute 0 or 59 seconds in the future:

//echo -a time is now $time | while (*:59 !iswm $time) noop | echo -a time is now $time | timertest $time 1 0 echo -a test message | timertest | echo -a timertest executes at $timer(test).time

This shows that you can't set a daily time until the hour:minutes is later than the current time's. In this example, even though the current time is 59 seconds later than the hour:minute:seconds time you specify for the timer's launch, it executes immediately because it ignores the seconds, then assumes that same-time means now instead of being 24 hours from now.

To have messages for 6 different chats, the /msg command in the timer would need to list the #channel name for that message. It is possible to send a message to several channels by separating them by only a comma.

/msg #channel1,#channel2 this message shows in both channels
© 2020 mIRC Discussion Forums