mIRC Bot Delay for mIRC


I have a question. Im using Nightbot for my commands. uptime, spam Protection etc. But I have my own Bot on mIRC. If someone type !commands, my Bot will respond to it. Its just a normal mIRC script with:

on :TEXT::*: {
if ($chan == #channelname) {
if ($1 == !commands) { msg $chan !uptime; !stream }

for example. How can I build in an DELAY so like this command, can only write every 5 seconds and the bot respond to it every 5 seconds? Since this is an own bot, it doesnt have any webinterface like Nightbot where you can change the delay with a slider.

Hope someone can help me.

Psuedo Code:
ON TEXT “!commands” IN CHANNEL #matt_thomas DO

CHECK VARIABLE %flood.matt_thomas, IF THERE RETURN <-RETURN - halts a currently executing script and allows the calling routine to continue processing.

set -uTIME %variable VALUE" <-will set a variable that decays over TIME in seconds


Actual script:

ON *:TEXT:!commands:#matt_thomas: {
if (%flood.matt_thomas) { return }
set -u10 %flood.matt_thomas On
msg $chan !uptime; !stream

Notes, you can leave the variable as %flood with no channel name after it to have a “global” delay in all channels, or you can do a channel specific variable that will only limit it per channel.

Change 10 to any value. I usually find around 6-8 seconds to work out ok, depending on speed of chat and amount of lines you do, you may want to tweak it.

Hey Mat,
I suggest you wrap you code in a code block;

like this.

Otherwise great code, but I’d like to offer an alternative.
Getting lots of timers can slow down mIRC if you ever think about expanding, making them per command, or thought this would be a great way to do something per user basis.

ON *:TEXT:!commands:#matt_thomas: {
  if (%flood.matt_thomas == $null || %flood.matt_thomas + 5000 < $ticks) {
    set %flood.matt_thomas $ticks
    msg $chan !uptime; !stream

This wil not use timers, but instead just check the local time and compare it (in miliseconds).
the 5000 says 5 second delay.
If you want a per command basis I’d suggest creating an easily expandable script like this;

ON *:TEXT:*:#matt_thomas: {

  // for easy naming - defines the the "response" for command $1
  var %command= %command. [ $+ [ $1 ] ] 

  // stores the last use of command $1
  var %floodcommand = %flood.matt_thomas. [ $+ [ $1 ] ] 

  // checks if %command exists, that is, the command var has a 'response' in it.
  // then checks if the %floodcommand (of that specific command) is non existant or far enough back
  if (%command && (%floodcommand == $null || %floodcommand + 5000 < $ticks)) {
    //sets the flood command time to $ticks
    set %flood.matt_thomas. [ $+ [ $1 ] ]  $ticks 

    // sends the response
    msg $chan %command

With that script, every command has a 5 Seconds own delay. You can now add commands by going into your variables and creating a command like this:
%command.!NAME ANSWER
for example:
%command.!commands !youtube, !Stream,!uptime

You don’t have to add anything to the function for more commands.
IE: hardcoding your ‘commands’ into the script isn’t nessecary. with this you can even let mods add commands.

1 Like

Thanks for the tips!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.