An efficient antispam and away autoreply script for mIRC




I add or update my scripts as it become needed. So, an antispam script is one among the first I did, since, no matter what channels you lurk in, there’s always a lamer sending ads of websites, channels, whatever.

An antispam script does nothing else that recognising some specified patterns in a query window, and ignoring it if it has the appearance of spam.

Briefly, you can download this addon to load from mIRC instead of adding the lines yourself. Instructions of use, along with possible changes you may need to make, are included in the TXT file itself. If you want to edit the lines yourself, or just want to know how the script works, continue reading.

The event in mIRC which triggers the opening of a query window is on OPEN, and the following lines will show how to use it:

on 1:OPEN:?:*:{....

The "?" specifies that the event will trigger only query windows, and the "*" specifies no particular text matches for now (we are going to include all the matches in the body of the script).

My script does 4 things: check if the messaging nick is an operator in one of the channels I am in, and in this case does not filter the message, otherwise it will be processed. If the user who sent you the message is in none of your channels, the message is ignored by default. If it is all ok, another procedure checks if I am away, and in that case tells the nick that I may not be at the computer, or, if it’s late, that I also may be sleeping. If the message is recognised as spam, the window is closed, and a minimized log window is open (if it doesn’t already exist), where you can check the supposed spam messages you received, so to correct te script if some of them weren’t spam.

Here’s the full text script (note: this script works under mIRC v5.9, don’t know about older versions):

on 1:OPEN:?:*:{
  var %Ghost
  set %Ghost 1
  var %Cnt
  set %Cnt 1
   :Loop
  //if ($nick isop $chan(%Cnt)) goto allok
  //if ($ialchan($nick,$chan(%Cnt),1) != $null) set %Ghost 0
  inc %Cnt
  //if (%Cnt < = $chan(0)) goto Loop
  //if (%Ghost == 1) goto absent
  if ($strip($1-) == hello,) goto lamer
  if ($strip($1-) == hello) goto lamer
  if ($strip($1-) === hi) goto lamer
  if ($strip($1-) == hallo) goto lamer
  if ($strip($1-) == holla) goto lamer
  if ($pos($strip($1-),#,1) != $null) goto lamer
  if ($pos($strip($1-),j o i n,1) != $null) goto lamer
  if ($pos($strip($1-),how are you,1) != $null) goto lamer
  if ($pos($strip($1-),how are u,1) != $null) goto lamer
  if ($pos($strip($1-),www.,1) != $null) goto lamer
  if ($pos($strip($1-),slm,1) != $null) goto lamer
  if ($pos($strip($1-),asl,1) != $null) goto lamer
  if ($pos($strip($1-),gamez,1) != $null) goto lamer
  if ($pos($strip($1-),leech,1) != $null) goto lamer
  if ($pos($strip($1-),join,1) != $null) goto lamer
  if ($pos($strip($1-),plz come,1) != $null) goto lamer
  if ($pos($strip($1-),pls come,1) != $null) goto lamer
  if ($pos($strip($1-),/server,1) != $null) goto lamer
  if ($pos($strip($1-),www.cheatos.com,1) != $null) goto lamer
  if ($pos($strip($1-),serv,1) != $null) goto lamer
  if ($pos($strip($1-),click here,1) != $null) goto lamer
  if ($pos($strip($1-),xguest,1) != $null) goto lamer
  if ($pos($strip($1-),/server,1) != $null) goto lamer
  if ($pos($strip($1-),check out my pics,1) != $null) goto lamer
  if ($pos($strip($1-),check my pics,1) != $null) goto lamer
  if ($pos($strip($1-),http://,1) != $null) goto lamer
  if ($pos($strip($1-),sex,1) != $null) goto lamer
  if ($pos($strip($1-),porn,1) != $null) goto lamer
  if ($pos($strip($1-),we need,1) != $null) goto lamer
  if ($pos($strip($1-),chat,1) != $null) goto lamer
  if ($pos($strip($1-),Matches for,1) == 1) goto Results
  goto allok
  :absent
  /query $nick Not in any of my channels. Message ignored.
  /close -m $nick
  goto end
  :lamer
  /query $nick This message's been detected as an invite/whatever else, so this window is being closed. My script can't be 100% accurate, so sorry if it's not your case.
  /close -m $nick
  //if ($window(@lamerz,1) == $null) /window -n @lamerz
  //aline -hp @lamerz 9 [ $time ] 7 < $nick > 8 $1-
  goto end
  :allok
  //if ($away == $true) {
    //if ($asctime(H) < 9) //query $nick [Automated Response] It is $asctime(H:nn) $+ $asctime(tt) here, and I am away ( $+ $duration($idle,2) idle), so I may be sleeping.
    else //query $nick [Automated Response] I am away ( $+ $duration($idle,2) idle). I could answer you if I'm here and the speakers are on ;-)
  }
  :end
}

HTML doesn't allow easy indenting, but when you'll copy/paste this in your mIRC/Remote panel, accessible by pressing the button , and then press the [OK] button, it will be automatically indented.

Important: check if your Remote Panel already contains an [on *:OPEN:?:...] event. In this case, either you did that script, so you don't need me to tell you how to modify it, or you had another script installed, like Polaris, Siralop, Invision, whatever and it probably includes an antispam routine itself, so you don't need this guide.

How you can customize this script:

  • Add new keywords: if you notice that some spam doesn't get filtered, you can add the peculiar words in it to the list, just by copying a line and substituting the keywords. For example, if they open a query window which starts like this: "Hello <yournick>," (while nobody usually opens such query windows just to chat), simply add a line like "if ($pos($1-,Hello <yournick>,,1) != $null) goto lamer" among the others.
  • Specify detailed patterns: you can also check case sensitive keywords. For example, if your nick is JoE^ and you want the above keywords to be case sentitive, put the same line, but substitute "$pos" with "$poscs" so it will become "if ($poscs($1-,Hello JoE^,,1) != $null) goto lamer". Also you can determine if the message must start with those keywords, and not just contain them. In that case, substitute "!= $null" with "= 1" so the line will become "if ($poscs($1-,Hello JoE^,,1) = 1) goto lamer".
  • Specify whole messages: you can as well filter exact sentences, instead of checking if a sentence contains some keywords. In that case simply add a line like "if ($1- == Hello,) goto lamer" which for example will trigger on evey query window equal to "Hello,". This is not case sensitive; if you want a case sensitive check substitute "==" with "===", like "if ($1- === Hello,) goto lamer".
  • Modify the sleep time: my supposed sleep time goes from 0:00 to 8:59; means that a query window received between these times will be answered with the "I am sleeping" message. You can correct this by modifying the Hour time, from 9 to 10 for example, if you want the interval to end at 9:59, or to 8, if you want instead 7:59. If you want to modify the first time, 0:00, you should also add some text to the script. It can be easily done, anyway I don't have right now the time to add a tutorial on this, plus I don't think it's of vital importance wheter the script guesses exactly wheter you are sleeping or not.

One thought on “An efficient antispam and away autoreply script for mIRC”

  1. [commenti dal vecchio sito]
    [comments from old website]

    Ephestione
    2010-02-21 12:09:47
    Thank you for your comment Abdul.
    This script surely worked very well back in my IRC days, several years ago.
    Anyway this script doesn’t allow you to set the message everytime, it just says that you’ve been idle, but you can easil modify it if you know something about mIRC scripting, to set a different message everytime.
    Abdul Q
    2010-02-21 04:09:58
    Hi, Thanks you for this. I’m just looking for something like this and I found it here. Hopefully it will working well.

    Btw, I’m just wondering about away message. If let say I away from my pc and go to shopping for a while, is there any button or command to set the away status first so the script will take an action?

Leave a Reply

Your email address will not be published. Required fields are marked *