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 ban enforcer and protection

Ban enforcement means kicking the users that have an address that matches the ban mask. When banning a normal user, a simple ban + kick routine is enough but when talking about tougher cases like clone bots (or just an army of idiots coming from a certain address), a good ban enforcement is a good thing to have. Also a ban enforcer may be running just on one or two operators so that other operators don't need to worry about technicalities. In order to remove users you or some other channel operator is naturally required to set the ban first but after that ban enforcement can handle the rest. This is simply done with on BAN event used in conjunction with enforceban alias. The enforceban alias uses $ialchan to get the number of users and goes through and kicks every user on the $ialchan list. Naturally you need a working Internal Address List (IAL) to use this event. The on BAN event uses @ prefix since the event uses operator-only commands.

The example script removes bans set on your address and deops the user that tried to ban you. This is very useful for preventing the abuse of ill-gained operator status. However if a real channel operator bans you, it's questionable whether you should be on the channel in the first place. If you try to ban yourself, the script halts. Note that a ban without deop is bad code.

The enforceban alias is separated from the on BAN event so that you can use it independently. If you set a ban and want to enforce it, it's a bit faster to send kick messages right away rather than wait the ban mode message from the server. The ban_and_enforce alias is an example. The alias has no routine to deop banned users. It's naturally a good idea to rename the alias to something more simple.

Example script

on @*:BAN:#: {
  if ( $banmask iswm $address($me,5) ) {
    ; If you try to ban yourself, halt
    if ( $nick == $me ) halt

    ; If someone else tried to ban you and you still have operator status,
    ; remove the ban and deop the person who set the ban
    mode $chan -ob $nick $banmask

  ; Kick everyone matching banmask (assuming that someone else didn't kick them first)
  else enforceban $chan $banmask Banned by $nick

; $1 = Channel, $2 = Ban mask, $3- = Message
alias enforceban {
  var %x = 1
  while ( $ialchan($2,$1,%x).nick ) {
    kick $1 $ifmatch $3-
    inc %x

; $1 = Channel, $2 = Ban mask
alias ban_and_enforce {
  mode $1 +b $2
  enforceban $1 $2 Banned

Last updated 2003-04-05, Janne 'Geetee' Nikula,