mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2016
Posts: 5
B
balrug Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2016
Posts: 5
OK so I've been screwing around with a quote system for a charity drive I'm running in 22 hours. I have spent all night trying to get the timer to run and it doesn't work. The basic script is as follows.

on *:TEXT:!fact:#: {
if ($nick isop # ) {
if ((%floodQUOTE) || ($($+(%,floodQUOTE.,$nick),2))) { return }
set -u10 %floodQUOTE On
set -u30 %floodQUOTE. $+ $nick On
msg $chan $read(heartfacts.txt)
}
else {
msg $chan Mods will one of you fact command please if it hasn't been used too recently?
}
}


Now what I would like is every 30 minutes for the bot to automatically pull a quote from said fact file. Seeing as it's a 24 hour charity drive my mods won't be online the whole time. I'm just having trouble figuring out where to put the line of code for the autotimer and how to script it.

Thank you so much.

Joined: Jun 2015
Posts: 84
F
Babel fish
Offline
Babel fish
F
Joined: Jun 2015
Posts: 84
I believe this should work and I fixed a small security vulnerability related to $read (always use the n switch when using $read)

Code:
on *:TEXT:!fact:#: {
  if ($nick isop # ) {
    if ((%floodQUOTE) || ($($+(%,floodQUOTE.,$nick),2))) { return }
    set -u10 %floodQUOTE On
    set -u30 %floodQUOTE. $+ $nick On
    msg $chan $read(heartfacts.txt,n)
    facts $chan
  }
  else {
    msg $chan Mods will one of you fact command please if it hasn't been used too recently?
  }
}

alias facts {
  if ($timer([facts]).type == online) { return }
  elseif ($timer([facts]).type == offline) {
    .timer[facts] 0 1800 msg $1 $read(heartfacts.txt,n)
  }
}


There may be a better way, but this was all I could think of at the current time.

When you first do the !fact command, it'll check if a timer is active that outputs facts, if a timer is active, it'll return and not execute the alias, if one isn't active, it'll become active and start outputting a random fact every 30 minutes.

Note: This will activate only if a mod uses the command, if you want it so that if only a user is there, then just add the tweet $chan to the else part of the code.


Link Copied to Clipboard