Mute ban with enforce

By FordLawnmower on Feb 21, 2011

  • This is a mute script with a few popups added to demonstrate how to use the /mute command. Feel free to edit them to suite your own needs.
  • For normal use, just paste the code in a new remote, save it with a unique filename and right click a nick on the nicklist to bring up the mute menu.
  • The /mute command is a local alias, so it can only be used inside the script. If you want a global alias, I've added /m (ie. /m nickname TimeinMinutes Reason) TimeinSeconds and Reason are optional.
    This script was requested by a lot of people because most mute scripts can be evaded with /hop in autovoice channels.
    After extensive testing, this can only be evaded if the client that sets the ban is de-oped
    or disconnected from the server.
    Keep in mind that this is not designed to be blacklist. No data is saved when you close mIRC. I got a little carried away making this, but that would just be silly :P
  • Thanks to mentok, Ricky and lots of folks on PeerCommons for testing this script :)
  • If your network uses a different syntax for setting mute bans, contact me with the info and I will be happy to edit this code for you.
;MuteBanEnforce by Ford_Lawnmower #Script-Help
menu nicklist {
  ..$iif(!$hget(MuteEnforce,$+($network,$chan,$address($$1,2))),$style(2)) RemoveMute $$1: {
    var %mask $+($network,$chan,$address($$1,2))
    hdel MuteEnforce %mask
    if ($timer(%mask).com) {
      .notice $$1 Your ban has been lifted early! You may now speak in $+($chan,.) Please try not to repeat the same activity that caused you to be muted.
      $+(.timer,%mask) off
    else mode $chan -b $+(~q:,$address($$1,2))
  ..Mute $$1
  ...3 Minutes:mute $$1 180 $$?="Reason for Muting $$1"
  ...5 Minutes:mute $$1 300 $$?="Reason for Muting $$1"
  ...10 Minutes:mute $$1 600 $$?="Reason for Muting $$1"
  ...30 Minutes:mute $$1 1800 $$?="Reason for Muting $$1"
  ...60 Minutes:mute $$1 3600 $$?="Reason for Muting $$1"
  ...Set Time: {
      var %length $$?="Length of ban in minutes"
      mute $$1 $calc(%length * 60) $$?="Reason for Muting $$1"
alias -l mute {
  var %nick $$1 
  if (%nick ison $chan) && ($regex($nick(#,$me).pnick,/[~&!@%]/)) {
    ialcheck %nick
    var %usermodes $replace($remove($nick(#,%nick).pnick,%nick),~,q,&,a,!,a,@,o,%,h,+,v), %addy $iif($address(%nick,2),$v1,%nick)
    mode $chan $+(+b-,%usermodes) $+(~q:,%addy) $str($+(%nick,$chr(32)),$len(%usermodes))
    hadd -m MuteEnforce $+($network,$chan,%addy) mute
    if ($$2 isnum) {
      $+(.timer,$network,$chan,%addy) 1 $$2 removeMute $+($network,$chan,%addy) $chan $+(-b+,%usermodes) $+(~q:,%addy) $str($+(%nick,$chr(32)),$len(%usermodes))
      msg $chan $+(,%nick,) You have been Muted! Duration: $duration($2) Reason: $iif($3-,$3-,Intolerable Behavior!)
    else msg $chan %nick You have been Muted! $+(Reason:,$iif($2-,$2-,Intolerable Behavior!))
  else echo -a Error: Either %nick is not on $chan or you do not have the correct privileges to use the mute command.
alias -l ialcheck {
  if (!$ial($1)) .who $1
alias -l removeMute {
  if ($($+($,$0),2) !ison $2) mode $2 -b $4
  else mode $2-
  hdel MuteEnforce $1
alias -l parseMode {
  tokenize 32 $1
  var %start 1, %finish $len($1), %+-, %modes -1, %location $+(parseMode,$chr(3),$network,$chr(3),$chan)
  while (%start <= %finish) {
    if ($mid($1,%start,1) isin +-) { %+- = $replace($v1,+,1,-,-1) | inc %modes }
    elseif ($mid($1,%start,1) isin qaohvb) {
      var %mode $+($v1,$($+($,$calc(%start - %modes)),2))
      hadd -m %location %mode $calc($hget(%location,%mode) + %+-)
    inc %start
  var %hash $regsubex($regsubex($str(.,$hget(%location,0).item),/(.)/g,$+($hget(%location,\n).data,$hget(%location,\n).item,$chr(32))),/(\b0[^\s]*)/g,)
  if ($hget(%location)) hfree $v1
  var %count 1, %max $numtok(%hash,32), %return, %temp
  while (%count <= %max) {
    %temp = $gettok(%hash,%count,32)
    %return = $+(%return,$chr(32),$iif($left(%temp,1) == -,$+(-,$mid(%temp,3)),$+(+,$mid(%temp,2))))
    inc %count
  return %return
On !*:rawmode:#: {
  checkMutes $network $chan $parsemode($1-)
alias -l checkMutes {
  var %network $1, %chan $2, %modes $3-
  tokenize 32 %modes
  checkMute %network %chan $*
alias -l checkMute {
  var %mode $left($3,2), %target $mid($3,3)
  if ((%mode isincs +v+h+o+a+q) && ($hget(MuteEnforce,$+($1,$2,$address(%target,2))))) mode $2 $replace(%mode,+,-) %target
  elseif ((%mode == -b) && ($hget(MuteEnforce,$+($1,$2,$gettok(%target,-1,58))))) mode $chan +b %target
;Syntax /m Nick TimeinMinutes Reason
alias m mute $$1 $iif($2 isnum,$calc($2 * 60),180 $2) $3-


Sign in to comment.
athena80   -  Jul 12, 2014
  • Invalid format: $replace (line 30, mute.mrc)
chachin   -  Oct 06, 2011

crazy script i give it a 9/10 and +1 like :)

Stewie1k94   -  Oct 05, 2011

great snippit, nice work again ford

Sachit Reddy   -  Sep 14, 2011

ford help can u change the command to !mute

Alco`   -  Jul 26, 2011

Hmmm a pitty... i love GODirc :(
Well thanks for all the replies guys!

Jethro   -  Jul 20, 2011

Also, 6.14 doesn't recognize the identifier $v1, so you have to change it to $ifmatch everywhere in the script. There may be other needed adjustments to be made if you can't upgrade for any reason. You're better off to do what ford suggested if you don't have enough know-how to modify the code to meet the compatibility.

FordLawnmower   -  Jul 20, 2011

6.14 is over 7 years old Alco`. If you want to load new scripts then you will need to use a newer version of mirc.exe.
I would suggest trying 6.35. 7.x may have some conflicts with your "god" scripts.
You can find other versions of mIRC here:
To use this code you will need at least 6.21.
Keep in mind, that only mIRC.exe needs to be replaced in your current mirc directory but you will have to run the mirc setup to get the file.

Alco`   -  Jul 20, 2011

This is what it replied...


FordLawnmower   -  Jul 19, 2011

@Alco` No idea what that is.. What is your mIRC version ?
Do this:

//echo -a $version

Thanks irchainscriptz :)

irchainscriptz   -  Jul 19, 2011

Dam FordLawnmower you always amaze me with your coding. Nice job!!

Alco`   -  Jul 19, 2011

Hey i removed the first line... so it shifted to 29 :p
I'm using GODirc v5.6 lite

FordLawnmower   -  Jul 19, 2011

@Alco` there is no $replace on 29 but there is one on 30.
What is your mIRC version ?

Alco`   -  Jul 19, 2011

Eh.. i can't get it to work... something wrong with line 29.
I get this notice: * Invalid format: $replace (line 29, Mute Script)

CrazyShady   -  Jun 26, 2011

okay. im on Peers right now in ur room. nick is Shady. talk to u there

FordLawnmower   -  Jun 26, 2011

@CrazyShady As with all scripts that use a users hostmask to set a ban, this script uses your ial to get the address.
In case your ial contains no data for a user you are trying to ban, this script will do a /who username to refresh your ial.
If your ial still doesn't return any data for the user in question, the script WILL, as a fail safe, use the nickname instead of the hostmask.
This is probably what happened. It's not a flaw in the script but rather a problem with your ial not staying up to date. This could happen if you have extreme lag causing your ial to be updated on a delayed basis.
If you are having problems with this that are unrelated to lag, please let me know. A small piece of code can fix this problem and make sure your ial stays up to date.

CrazyShady   -  Jun 26, 2011

Well for some reason it did. I'm not sure why though.

FordLawnmower   -  Jun 24, 2011

It doesn't remove the ban till the time runs out CrazyShady . The ban has nothing to do with the nickname. It is set on the hostmask.
Parting a room and changing your nick has NO effect on this script.

CrazyShady   -  Jun 24, 2011

Thats the only flaw i found

CrazyShady   -  Jun 24, 2011

I tested this script out, and come to find out, if the user you muted leaves the room and changes their nick and returns to the room they were muted in, it removes the ban that was placed when they were muted.

Jethro   -  Feb 22, 2011

It was just an idea. Perhaps it was not a valid one by itself to apply to yours. I did mention that my approach only requires one mode to prefix all the tokens... Anyway, I shouldn't derail myself from the intended path of this thread. lol

FordLawnmower   -  Feb 21, 2011

That's not really parsing it if you have to parse it first.
Jethro_ Said:

You merely need to specify one +b or -b to have all the strings prefixed with a channel mode.
Half of the goal of my parsemode alias is to pair the mode up with the nick or address it is being applied to.

I'm sure there are a lot of other ways to parse the rawmodes but your alias doesn't get it done.
The idea is to parse the rawmodes , just as they are returned from the event..
From your example:

//echo -a $parsemode(+b this that theother)

This should have been::

//echo -a $parsemode(+bbb this that theother)

With your code this would return::

+bbbthis +bbbthat +bbbtheother

I don't think that output would serve any purpose here.

Thanks for the comment. It just reminds me of what a headache it is to parse rawmodes properly.

Jethro   -  Feb 21, 2011

Ford, I believe you can do it as such:

alias parsemode {
  noop $regex($1,/(?!\54)([+-][ $+ $chanmodes $+ ])/)
  return $gettok($regsubex($1,/(\S+)/g,$+($regml(1),\1)),2-,32)

You merely need to specify one +b or -b to have all the strings prefixed with a channel mode.> //echo -a $parsemode(+b this that theother)will return > +bthis +bthat +btheother

FordLawnmower   -  Feb 21, 2011

Thanks Dean :)
Thanks Jethro_ :)
A large section of this script is the alias parsemode, which is used to determine which modes are actually changed.
If you remove the -l from this alias you can see what it does and why it's needed.

//echo -a $parsemode(+bbb this that theother)

Will return::

+bthat +btheother +bthis


//echo -a $parsemode(+b-b+b this this this)

Will only return The mode that actually changed::

//echo -a $parsemode(+b-b+b-b this this this this)

Will return nothing, since nothing actually changed.
Boring , I know. But it's needed to prevent someone from tricking you into removing your own ban. It also helps prevent you from being flooded off the server for reversing modes that were never actually changed.

By the way. This version of parsemode, only parses qaohvb, as these were the only ones required by this script.
Thanks for the comments :)

Jethro   -  Feb 21, 2011

Nice work. I know you have a great mind to express it into this snippet.

_Dean_   -  Feb 21, 2011

didnt think that a mute script could be large like this, but you probably thought in all ways to override this mute, i will recomend it

FordLawnmower   -  Feb 21, 2011

Thanks SoulMuncher

SoulMuncher   -  Feb 21, 2011

It's decent

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.