Note: The mainteinance of the scripting examples is discontinued since I no longer have an interest to continue doing so. The pages will remain here, for now, but that might not be the case in the future. You are free to download all the material on these pages and set a up mirror, or even continue the maintenance of the material by enhancing the examples yourself.

All the material in these examples are for the mIRC version 6.03. It is very likely that some or most of these examples won't work in future versions.

Scripting a blacklist

There are times when there are users who behave so badly that you will never want to see them again. It might be spamming, extreme rudeness or something along that lines. Normally you can just set a ban and never remove it. However ban lists have limits, sometimes a limit way too low. Then you have keep a separate list which has all the addresses while only a few of them being active bans. Another case might be when you have a bot but you don't want to synchronize the ban lists for some reason.

Like always there are many ways to do a blacklist. Some not-so-elegant scripts call this feature a s***list but I think blacklist sounds nicer. :-) You can use your own user level systems but mIRC's internal list is the easiest to use. The command to add an address to a specified level is
/auser <level> <address> <comment>
A similar one is
/guser <level> <nick> <type> <comment>
which uses /userhost to look up the address if it's not already in the Internal Address List (IAL). So use /auser if you have a working IAL and /guser if you don't.

The best way to prevent someone talking or using the channel is to never let the person join in the first place. As soon as you see someone in the blacklist level joining, the best way is to set the ban right away. The $maddress identifier has the address mask that was used for matching i.e. if you had blacklisted *!*user@*.example.com, the $maddress identifier would equal to *!*user@*.example.com. Acquiring the info field for the address is a bit more tricky but not too hard. The info field that is used for the kick message is can be found from the $ulist identifier's .info property when you give search for the first match for the entry in $maddress.

Example script

; $1 = Address, $2- = Comment blacklists someone
; No parameters lists all blacklisted people
alias blacklist {
  if ( !$1 ) ulist blacklist
  else auser blacklist $1 $2-
}

on @blacklist:JOIN:#: {
  mode $chan +b $maddress
  kick $chan $nick Blacklisted: $ulist($maddress,blacklist,1).info
}

That script is fine for light or rare use. However it's more common that the blacklist script works not only on specified addresses but also on specified networks and channels. The following script will use the info field of the access level entries for the network and channel information. An entry in the Tools/Remote/Users should look like:
blacklist:<address> <network> <channel> <reason>

The network field accepts either network name (like undernet) or a server mask (like *.undernet.org). It is possible to have multiple network names separated by commas but not multiple server masks. The channels can also be either a comma separated list of channels (like #chat,#idle,#nightcafe) or a wildcard mask (like #*chat*). The most useful application of wildcard masks is naturally to match all networks or channels. To make the comparisons easier, the script uses the /tokenize command to put the info field into $1-. That way the network is in $1, the channel is in $2, and the message is in $3-.

Example script

on @blacklist:JOIN:#: {
  tokenize 32 $ulist($maddress,blacklist,1).info
  if ( ($istok($1,$network,44)) || ($1 iswm $server) ) {
    if ( ($istok($2,$chan,44)) || ($2 iswm $chan) ) {
      mode $chan +b $maddress
      kick $chan $nick $iif($3,Blacklisted: $3-)
    }
  }
}

As you can see, this script doesn't include any aliases to conviniently add, remove, and manipulate people in the blacklist. That is left for you to implement yourself. It might be a good idea to do a dialog if you wish for userfriendly interface.

The access level definitions might be a bit confusing so here are a few examples of blacklist entries as they would appear in Tools/Remote/Users.

Blacklist *!user@* everywhere with the message "Too common ident reply, make something more unique"
blacklist:*!user@* * * Too common ident reply, make something more unique

Blacklist the most common Finnish addresses on Undernet #sweden and #sverige with the reason ".fi luser"
blacklist:*!*@*.fi undernet #sweden,#sverige .fi luser
blacklist:*!*@*.suomi.net undernet #sweden,#sverige .fi luser
blacklist:*!*@*.kanetti.com undernet #sweden,#sverige .fi luser

Blacklist *!*geetee@*.htv.fi on all EFnet channels with the message "your script doesn't work!"
blacklist:*!*geetee@*.htv.fi efnet * your script doesn't work!

Blacklist *!*@mirc.com on #mirc on all networks with message "moo"
blacklist:*!*@mirc.com * #mirc moo


Last updated 2003-04-05, Janne 'Geetee' Nikula, jn-mirc@zkelvin.net