Type modes to set them

By Yawhatnever on May 07, 2012

Type channel modes to set them on the channel.

e.g.

+m
-m+k password
+v-o nickname nickname
+b nickname/address

This is a snippet from one of my scripts, so it also allows [!@.]ban and !unban for anyone who might be used to that format for setting or removing bans using custom or network service bots.

Holding control when pressing enter will allow you to send messages that weren't intended to be commands.

Banning and modes +e/+I will use the nicknames address if it's in the internal address list but will use the nickname if it's not.

Setting modes +aohv and using +beI will set the modes on yourself if no other parameters were given.

Bans and exceptions use channel ban formats if a channel was given rather than a nickname. (must be supported by the network)

The regex for modes could be improved to be more specific, but I figure it's up to the user to know what modes they're trying to set...

Post anything else if you want to.

on *:INPUT:#:{
  if ($ctrlenter) return
  elseif ($regex($1,/^([!@.](?i)(un)?ban|[+-](?-i)[beI])\b/S)) { 
    var %n $iif($2, $2, $me) 
    mode # $iif(ban isin $1, $iif($regex($1,/^[!@.]un/Si), -b, +b), $1) $&
      $iif($regex($2,/^#/S), ~c: $+ $2, $iif($ial(%n), $mask($v1,2), %n)) 
  }
  elseif ($regex($1,/^[+-][a-z]+([+-][a-z]+)?$/Si)) { 
    mode # $1 $iif($2, $2-, $str($+($me, $chr(32)), $countcs($1, a, o, h, v))) 
  }
 else return
 haltdef
}
/*
* 'else return' could be removed if you put the /haltdef inside each of the if-statements. Using this method of 'else return' 
* assumes you want each match inside the input event to be prevented from being sent to the channel, meaning you don't 
* have to add the /haltdef to the commands after each if-statement because the /haltdef at the end will be reached.
* The benefits of this method are clearer if you have a lot more if-statements.
*/

Comments

Sign in to comment.
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.