IRC: Make a cool antispam script

 

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:

 

ca