on 1:OP:#: {
  if ( %popp == on ) && ( $opnick == $me ) { mode %poppc -o+b %poppn $address(%poppn,2) | inc %knum 1 | kick %poppc %poppn Personal %pokpw Protection (# $+ %knum $+ ) $sw | .timer 1 10 mode %poppc -b $address(%poppn,2) | unset %popp* | unset %pokpw } | goto end2
  :end2
}
on 1:DEOP:#: {
  if ( %pop == on ) && ( $opnick == $me ) && ( $nick != $me ) && ( $nick != ChanServ ) { set %popp on | set %poppn $nick | set %poppc $chan | set %pokpw Deop | .msg ChanServ op $chan $me } | goto end2
  :end2
}
on 1:KICK:#: {
  if ( %pkp == on ) && ( $nick != ChanServ ) && ( $nick != $me ) && ( $knick == $me ) { set %popp on | set %poppn $nick | set %poppc $chan | set %pokpw Kick } | goto end2
  :end2
}
on 1:BAN:#: {
  if ( %pbp == on ) goto pbp | goto end1
  :pbp
  if ( $nick == ChanServ ) goto end1 | goto pbp1
  :pbp1
  if ( $nick == $me ) goto end1 | goto pbp2
  :pbp2
  if ( $bnick == $me ) { .msg ChanServ unban $chan me | mode $chan -o+b $nick $address($nick,2) | inc %knum 1 | kick $chan $nick Personal Ban Protection (# $+ %knum $+ ) $sw | .timer 1 10 mode $chan -b $address($nick,2) | goto end1 } | goto pbp3
  :pbp3
  if ( $banmask == $address($me,1) ) { .msg ChanServ unban $chan me | mode $chan -o+b $nick $address($nick,2) | inc %knum 1 | kick $chan $nick Personal Ban Protection (# $+ %knum $+ ) $sw | .timer 1 10 mode $chan -b $address($nick,2) | goto end1 } | goto pbp4
  :pbp4
  if ( $banmask == $address($me,2) ) { .msg ChanServ unban $chan me | mode $chan -o+b $nick $address($nick,2) | inc %knum 1 | kick $chan $nick Personal Ban Protection (# $+ %knum $+ ) $sw | .timer 1 10 mode $chan -b $address($nick,2) | goto end1 } | goto pbp5
  :pbp5
  if ( $banmask == $address($me,3) ) { .msg ChanServ unban $chan me | mode $chan -o+b $nick $address($nick,2) | inc %knum 1 | kick $chan $nick Personal Ban Protection (# $+ %knum $+ ) $sw | .timer 1 10 mode $chan -b $address($nick,2) | goto end1 } | goto pbp6
  :pbp6
  if ( $banmask == $address($me,4) ) { .msg ChanServ unban $chan me | mode $chan -o+b $nick $address($nick,2) | inc %knum 1 | kick $chan $nick Personal Ban Protection (# $+ %knum $+ ) $sw | .timer 1 10 mode $chan -b $address($nick,2) | goto end1 } | goto end1
  :end1
}
