;  Revenge - by badseeds
;  Version 2.0
;  Released 15 Jan 2000

;[menu]
menu menubar,channel {
  Revenge
  .Clear Memory:{ rev.unset | echo -a *** Revenge memory cleared }
  .-
  .Revenge for All...
  ..On:rev all on
  ..Off:rev all off
  .Revenge for Kick...
  ..On:rev kick on
  ..Off:rev kick off
  .Revenge for Ban...
  ..On:rev ban on
  ..Off:rev ban off
  .Revenge for Deop...
  ..On:rev deop on
  ..Off:rev deop off
  .-
  . $iif($active ischan,Add # to list) :{ var %rchans = $revr(setup,chans) | if ($chan isin %rchans) { echo -a *** $chan already exists in revenge channel list } | else { revw setup chans $iif(%rchans == ?,$chan,%rchans $chan) | echo -a *** Added $chan to revenge channels } }
  . $iif($active ischan,Del # from list) :{ var %rchans = $revr(setup,chans) | if ($chan isin %rchans) { if ($gettok(%rchans,2,32) == $null) { revw setup chans ? } | else { revw setup chans $replace($remove(%rchans,$chan),$chr(32) $+ $chr(32),$chr(32)) } | echo -a *** Removed $chan from revenge channels } | else { echo -a *** $chan does not exist in revenge channel list } }
  . $iif($active !ischan,Add chan to list...):{ var %rchans = $revr(setup,chans) | var %nchan = $$?="What channel do you wish to add to revenge list? $crlf $+ Note that you must have Founder/Sop/Aop access in this channel" | if (%nchan) { if ($left(%nchan,1) != $chr(35)) { var %nchan = $chr(35) $+ %nchan) } | revw setup chans $iif(%rchan == ?,%nchan,%rchan %nchan) | echo -a *** Added %nchan to revenge channel list } }
  . $iif($active !ischan,Del chan from list...):{ var %rchans = $revr(setup,chans) | var %nchan = $$?="What channel do you wish to remove from revenge list?" | if (%nchan) { if ($left(%nchan,1) != $chr(35)) { var %nchan = $chr(35) $+ %nchan) } | if ($gettok(%rchans,2,32) == $null) { revw setup chans ? } | else { revw setup chans $replace($remove(%rchan,%nchan),$chr(32) $+ $chr(32),$chr(32)) } | echo -a *** Removed %nchan from revenge channel list } }
  .Show list:{ echo -a *** Revenge is enabled in: $revr(setup,chans) }
  .Wipe list:{ var %temp = $$?!="Are you sure you want to wipe the revenge channel list?" | if (%temp == $true) { revw setup chans ? | echo -a *** Revenge channel list wiped } | else { echo -a *** No changes made to revenge channel list } }
}

on *:load:{ echo -a *** badseeds Revenge v2.0 [released 15th Jan 2000] | echo -a *** Script loaded | echo -a *** This script was created by badseeds (badseeds@sade.com @#Helpdesk irc.dal.net) | .ial on }
;[aliases]
alias rev {
  if ($1 == kick) || ($1 == ban) || ($1 == deop) {
    var %revtype = $ifmatch
    if ($2 == on) { .enable #rev.[ $+ [ %type ] ]  | echo -a *** $upper($left($1,1)) $+ $lower($mid(2,$len($1),1)) Revenge Enabled. }
    elseif ($2 == off) { .disable #rev. [ $+ [ %type ] ] | echo -a *** $upper($left($1,1)) $+ $lower($mid(2,$len($1),1)) Revenge Disabled. }
  }
  elseif ($1 == all) {
    if ($2 == on) { .enable #rev.kick | .enable #rev.ban | .enable #rev.deop | echo -a *** Kick, Ban and Deop Revenge Enabled. }
    elseif ($2 == off) { .disable #rev.kick | .disable #rev.ban | .disable #rev.deop | echo -a *** Kick, Ban and Deop Revenge Disabled. }
  }
  elseif ($1 == chans) {
    if ($2 == list) { echo -a *** Revenge channels are: $revr(setup,chans) }
    elseif ($2 == add) { echo -a *** Revenge channels are $revr(setup,chans) | var %rev.add = $$?="Type the channel you want revenge in $crlf $+ Note: You should have Aop/Sop/Founder access to this channel" | if ($left(%rev.add,1) != $chr(35)) { var %rev.add = $chr(35) $+ %rev.add } | var %rev.chans = $revr(setup,chans) %rev.add | echo -a *** Added %rev.add to Revenge Channels }
    elseif ($2 == del) { echo -a *** Revenge channels are $revrd(setup,chans) | var %rev.del = $$?="Type the channel you want to remove from revenge $+ Note: You must include # as the channel name' | if ($left(%rev.del,1) != $chr(35)) { var %rev.del = $chr(35) $+ %rev.del } | var %rev.chans = $replace($remove($revr(setup,chans),%rev.del),$chr(32) $+ $chr(32),$chr(32)) | echo -a *** Removed %rev.del from Revenge Channels }
  }
  else { echo -a *** Syntax: /rev [kick/ban/deop/all/chans] [on/off/add/list/add/del] }
}
alias rev.set { set %rchan $1 | set %rnick $2 | set %rwhy $3 | set %raddy $address($2,3) | set %rtime $ctime | .enable #rev.rejoin | .enable #rev.reop }
alias rev.unset { unset %rchan %rnick %rwhy %raddy %rtime | .disable #rev.reop }
alias rev.addons { return [badseeds revenge2.0] }
alias revr { if ($exists($mircdirrevenge.ini) == $false) { write -c $mircdirrevenge.ini [setup] | writeini $mircdirrevenge.ini setup bantime 60 | writeini $mircdirrevenge.ini setup chans ? } | return $readini -n $mircdirrevenge.ini $1 $2 }
alias revw { writeini $mircdirrevenge.ini $1 $2 $3- }

;[remotes]
#rev.kick off
on *:kick:#:{
  var %revk.chans = $revr(setup,chans)
  if ($knick == $me) && ($nick != $me) && ($chan isin %revk.chans) {
    rev.set $chan $nick kick
  }
}
#rev.kick end
#rev.ban off
on *:ban:#:{
  var %revk.chans = $revr(setup,chans)
  if ($banmask iswm $address($me,5)) && ($nick != $me) && ($me isop $chan) && ($chan isin %revk.chans) {
    .chanserv op $chan $me
    rev.set $chan $nick ban
    .mode $chan -bo+b $banmask $nick $iif($address($nick,3),$address($nick,3),$nick)

  }
}
#rev.ban end
#rev.deop off
on *:deop:#:{
  var %revk.chans = $revr(setup,chans)
  if ($opnick == $me) && ($nick != $me) && ($nick != ChanServ) && ($chan isin %revk.chans) {
    rev.set $chan $nick deop
  }
}
#rev.deop end
#rev.rejoin on
on *:notice:All bans on * for * have been cleared.:*:{ if ($nick == ChanServ) { .raw join $4 | .enable #rev.reop | set %rev.acc $4 } }
on *:join:%rchan:{ if ($chan == %rev.acc) && (%rnick ison $chan) { if ($nick isop $chan) { .chanserv deop $chan %rnick } | if ($me isop $chan) { .kick $chan %rnick Woops, you're quick to return. Oh well I'll fix that. } } }
#rev.rejoin end
#rev.reop off
on *:op:%rchan:{
  if ($opnick == $me) {
    if (%rnick ison $chan) {
      if (%rnick isop $chan) { .mode $chan -o %rnick }
      .ban -u [ $+ [ $revr(setup,bantime) ] ] $chan %rnick 3
      .kick $chan %rnick Revenge for the %rwhy $duration($calc($ctime - %rtime)) ago $addons
    }
  }
}
#rev.reop end
raw 474:*:{ .chanserv unban $2 $me }
