Mass Deop Protection - mIRC

By contr0l on Jul 26, 2015

Little Mass Deop Protection script I wrote years ago.

;Mass Deop Protection with Exclusion List
;Mass Deop Protection by contr0l
;
;Commands:
;- /deopprot on/off
;- /d.exclude <-dl> nick
;  -- /d.exclude nick  adds a nick
;  -- /d.exclude -d nick  removes a nick
;  -- /d.exclude -l  lists exclusions
;
;Exclusion list is for you to have a list of valid ops,
;and if they attempt a massdeop, this script wont trigger.

;Note: only have one person in a channel run this at a time

;create exclusion file
on *:load:var %d $d.ex | if !$isfile(%d) { write -c %d }

;cleanup
on *:unload:write -c $d.ex | .remove $d.ex

menu menubar,channel {
  -
  Mass Deop Protection $+([,$group(#deopprot),])
  .$iif($group(#deopprot) == on,$style(3)) On:deopprot on
  .$iif($group(#deopprot) == off,$style(3)) Off:deopprot off
  .-
  .Exclusion List $+([,$lines($d.ex),])
  ..Add a Nick:var %el $?="Enter a nick to exclude" | if %el { d.exclude %el }
  ..Remove a Nick:var %el $?="Enter a nick to remove from exclusion list" | if %el { d.exclude -d %el }
  ..-
  ..List Exclusions:d.exclude -l
  ..Clear Exclusions list:write -c $d.ex | echo -a :: Exclusions List Cleared!
  -
}

;alias to turn protection on an off.
alias deopprot { if $1 == on { .enable #deopprot | echo -a :: Mass Deop Protection turned On. } | elseif $1 == off { .disable #deopprot | echo -a :: Mass Deop Protection turned Off. } }

;alias to return exclusion file
alias -l d.ex { return $+(",$scriptdir,d.exclude.txt,") }

;alias for exclusion list
alias d.exclude {

  ;set a var holding the path and file for the exclusion list
  var %d $d.ex

  ;if wasn't called as an identifier...
  if !$isid {

    ;check for -d switch and remove nick
    if $left($1,2) == -d && $len($1) == 2 && $2 { if $read(%d, w, $+(*,$2,*)) { write -dl $+ $readn %d | echo -a :: $2 was removed from Deop Exclusion List. } }

    ;check for -l switch to list exclusions
    elseif $left($1,2) == -l && $len($1) == 2 && !$2 { echo -a :: Listing Exclusions... | var %i 1 | while %i <= $lines(%d) { echo -a %i $+ ) $read(%d,%i) | inc %i } | echo -a :: EOF }

    ;if no switches were passed, check if the nick is in the exclusion list, if not, add.
    else { if !$read(%d, w, $+(*,$1,*)) { write %d $1 | echo -a :: $1 has been added to Deop Exclusion List. } }
  }
  else {

    ;if was called as an identifier, check for nick, and return result.
    if $read(%d, w, $+(*,$1,*)) { return $true }
  }
}
#deopprot on

;when deop event occurs...
on !@*:deop:#: {

  ;check if person who is deop'n is not in the exclusion list.
  if (!$d.exclude($nick)) {

    ;add each deop'd nick to a hash entry, and clear it in 5 seconds.
    .hadd -mu5 mdp $opnick

    ;if the number of deop'd nicks still in the hash table >= 4 ... mass deop detected.
    if ($hget(mdp,0).item >= 4) {

      ;make sure you werent deopd yourself
      if ($opnick != $me) {

        ;if you weren't deop'd proceed to kill the person doing the deop'n
        mode # -o+b $nick $address($nick,2)
        kick # $nick Mass deop detected...

        ;loop thru and reop all nicks that were deop'd by the loser..
        var %i $hget(mdp,0).item | while (%i) { mode # +o $hget(mdp,%i).item | dec %i }

        ;notify channel of prevention, and clear hash table
        .timer 1 1 msg # Mass Deop Prevented! | hfree mdp
      }

      ;if you were one of the ones deop'd, notify of detection.
      else .timer 1 1 msg # Mass Deop Detected, I'n no longer Op'd to prevent ;/
    }
  }
}
#deopprot end

Comments

Sign in to comment.
dma   -  Nov 05, 2015

does it still work?

 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.