Ultra Kick/Ban Command

By Serpentsounds on Apr 20, 2011

Okay, so the "Ultra" kinda implies some profound greatness, but my personal kick and ban commands do only what they sound like, haha. However, I do think that they accomplish that pretty well.

The banning accepts multiple users, an optional channel, makes full use of $modespl, including redundant address checking, and also has the option to remove all modes from the user(s) (i.e. qaohv). The kicking also accepts multiple users, an optional channel, with optional kick reasons to insert (or a default message). The combination - kickban - is a short and sweet alias, but allows you to do both at once.

This all works for me, but please be sure to point out any errors.

I don't write much mIRC script anymore, but if I do update this script, it will probably be to add wildcard and regex support to nicknames (too bad, I'm too lazy to do it right now, but it sounds like a good idea).

COMMANDS USAGE:

k.def - The default kick message stored as an identifier. Edit this directly to change the message displayed when no kick message is specified.

k.delim - The ASCII number of the delimiter used to mark optional kick messages. Edit this directly to change it. More info in the /k description below.

k - The kicking alias. You can specify multiple users, an optional channel, and optional messages. If you don't specify a channel, the active channel will be used. If you specify a kick message, it needs to come directly after the corresponding nickname, and also needs to be enclosed in colons in the corresponding ASCII character of the number return by $k.delim (the default is 58, or a colon). The examples below use a colon as the delimiter.

Example usage:

/k ben jim bob
Kick ben, jim, and bob using the default message, all from the active channel.

/k ben :get outta here!: jim bob :Seeya!
Kick ben with the message "get outta here!", bob with the default message, and bob with the message "Seeya!", all from the active channel.

/k #otherchannel ben jim :Adios!: bob
Kick ben with the default message, jim with the message "Adios!", and bob with the default message, all from channel "#otherchannel".

b.type - The ban type used for /b. Edit this directly to change the ban type. The default is type 2 (!@host).

b - The banning alias. You can specify multiple users, the option to also strip all modes from the users (qaohv, that is: owner, protect, operator, halfop, and voice), and an optional channel. To strip modes, make the FIRST parameter be "+m" (first means BEFORE the channel name, if you specify one). After the switch and the channel name, only nicknames are valid. The ban will attempt to ban the desired address type (default of 2), but if an IAL entry isn't found, it will use nick!@ instead.

Example usage:

/b +m ben jim bob
Ban ben, jim, and bob from the active channel, and also strip all modes from them.

/b #otherchannel ben jim bob
Ban ben, jim, and bob from "#otherchannel".

/b +m #otherchannel ben jim bob
Ben ben, jim, and bob from "#otherchannel", and also strip all modes from them.

/b joe
Ban joe from the active channel.

kb - The kicking AND banning alias. This will do both in one command. The parameters are a mix of the first two: you can specify the "+m", and optional channel, and also the delimiter-enclosed kick messages.

Example usage:

/kb +m #otherchannel ben :one down: jim :two down: bob :last one!:
First, ban ben, jim, and bob from #otherchannel while stripping all modes from them, in the style of /b. Next, kick ben with the message "one down", jim with the message "two down", and bob with the message "last one!", all from #otherchannel, in the style of /k.

/kb joe
Ban and kick joe (with the default message) from the active channel (modes are not stripped).

alias k.def return ye
alias k.delim return 58
alias k {
  var %x 1,%c $active,%nicks,%mode 0
  if ($left($1,1) == $chr(35)) var %x $calc(%x + 1),%c $1
  tokenize 32 $($+($chr(36),%x,-),2)
  while ($1) {
    var %n $v1,%nicks $addtok(%nicks,%n,32),%msg $k.def
    if ($left($2,1) == $chr($k.delim)) {
      noop $regex($2-,/ $+ $chr($k.delim) $+ ([^ $+ $chr($k.delim) $+ ]*)/)
      var %msg $regml(1)
      tokenize 32 $($+($chr(36),$calc($numtok($regml(1),32) + 2),-),2)
    }
    else tokenize 32 $2-
    kick %c %n %msg
  }
}

alias b.type return 2
alias b {
  var %x 1,%c $active,%mm,%mp,%addrs,%mode 0
  if ($1 == +m) var %mode 1,%x 2
  if ($left($($+($chr(36),%x),2),1) == $chr(35)) var %c $($+($chr(36),%x),2),%x $calc(%x + 1)
  tokenize 32 $($+($chr(36),%x,-),2)
  while ($1) {
    var %n $v1,%a $iif($address(%n,$b.type),$v1,$+(%n,!*@*))
    tokenize 32 $2-
    noop $regex($nick($chan,%n).pnick,/([~&@%+]*)/)
    if ($regml(1)) && (%mode) var %mm $+(%mm,-,$replace($regml(1),~,q,&,a,@,o,%,h,+,v)),%mp %mp $str($+(%n,$chr(32)),$len($regml(1)))      
    if (!$istok(%addrs,%a,32)) var %mm $+(%mm,+b),%mp %mp %a,%addrs $addtok(%addrs,%a,32)
    noop $regex(%mm,/((?:[+\-]?[a-z]){ $+ $modespl $+ })/)
    if ($regml(1)) {
      mode %c $regml(1) $gettok(%mp,1- $+ $modespl $+ ,32)
      var %mm $mid(%mm,$calc($len($regml(1)) + 1)),%mp $gettok(%mp,$calc($modespl + 1) $+ -,32)
    }
  }
  if (%mm) mode %c %mm %mp
}

alias kb {
  b $regsubex($1-,/ $+ $chr($k.delim) $+ [^ $+ $chr($k.delim) $+ ]*( $+ $chr($k.delim) $+ |$)/g,$null)
  if ($1 == +m) tokenize 32 $2-
  k $1-
}

Comments

Sign in to comment.
Serpentsounds   -  May 14, 2011

Nope, you didn't miss it. I'll probably edit one of those in as soon as I do it.

 Respond  
iGlitch   -  May 14, 2011

You should add an unban command. Or is there one, and iJust missed it, and now iLook like an ass?

 Respond  
Bielie   -  Apr 21, 2011

looks complicated i like it :D

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.