Difference between revisions of "Clear-Chanlev Script for QuakeNet"

From Scriptwiki
Jump to: navigation, search
m (cc.remove explicitly set to $false at start now, thanks faile)
(Script updated to work with Q9. Tested with version 1.00)
Line 1: Line 1:
Clear-Chanlev Script by Kickchon (for Q and L on QuakeNet) (v2.0)
+
; ClearChanlev script by doomie
This script removes all known users on a #channel except owners or removes Q/L completely from #channel.
+
;  #help.script @ QuakeNet
 +
;
 +
;
 +
; You can use this script by typing:
 +
;
 +
;        /clearchanlev [-c|-r] #channel
 +
;
 +
;  Note, that you must be authed and owner of #channel.
 +
;
 +
;  Flags:
 +
;          * -r ... Resets the script, i.e. cleans everything up. One usually doesn't need that flag, however, if something didn't work,
 +
;                    one can use it.
 +
;          * -c ... If you use this flag, the script will remove you from the channel aswell. This means, that Q will leave the channel
 +
;                    completly. Note that you can _NOT_ reverse it!
 +
;
 +
;
 +
;  Example output:
 +
;
 +
;      ClearChanlev: -----------------------------
 +
;      ClearChanlev: Now beginning to remove all chanlevs from channel #channel except yours!
 +
;      ClearChanlev: Receiving own auth now!
 +
;      ClearChanlev: ...done.
 +
;      ClearChanlev: Saving chanlev now...
 +
;      ClearChanlev: ...done.
 +
;      ClearChanlev: There are 2 lines to send. This will take approximatly 4 seconds. Removing...
 +
;      ClearChanlev: ...done.
 +
;      ClearChanlev: Cleaned up!
 +
;      ClearChanlev: -----------------------------
 +
;
  
; # Clear-Chanlev Script by Kickchon (for [[Q]] and [[L]] on QuakeNet) (v2.0)
+
; Returns the milliseconds between every message sent to Q
; # This script removes all known users on a #channel except owners or removes Q/L completely from #channel.
+
; If you excess flood, you should increase this value to 4000 or even 5000.
; # Please do nothing after typing /clearchanlev until you get a finish/error message.
+
alias -l ClearChanlev.Delay { return 3000 }
;
+
 
; # Needs Owner Access on specified #channel and you have to be authed.
+
; $1 = #channel
; # It will not remove other Owners.
+
;
;
+
; flags:
; # Use /clearchanlev #channel or /clearchanlev #channel -remove if you want to remove Q/L from a channel.
+
;   -c --complete = deletes the complete chanlev, inclusive owner. This will
;
+
;                   result in Q parting.
; # Kickchon, staff member on Quakenet
+
;   -r --reset    = resets the scripts in case something didn't work the last time.
;
+
alias ClearChanlev {
; # If you think there's a bug in this Script, please contact someone in #help.script on Quakenet.
+
  echo -s ClearChanlev: -----------------------------
+
  var %i = 1, %c, %ClearChanlev.Complete = 0, %r, %ClearChanlev.Force = 0, %ClearChanlev.Channel
[[Aliases|alias]] clearchanlev {
+
  while (%i <= $0) {
  [[if-Then-Else|if]] (!$1) {
+
    %c = $ [ $+ [ %i ] ]
     [[echo]] [[$color]](info) -at *** Clear-Chanlev: You need to specify the channel.
+
    if (%c == -c) || (%c == --complete) {
 +
      %ClearChanlev.Complete = 1
 +
    }
 +
    elseif (%c == -r) || (%c == --reset) {
 +
      %ClearChanlev.Force = 1
 +
    }
 +
     elseif ($left(%c, 1) == $chr(35)) {
 +
      %ClearChanlev.Channel = %c
 +
    }
 +
    inc %i
 
   }
 
   }
   [[if-Then-Else|elseif]] (Q !ison $1) && (L !ison $1) {
+
   if (%ClearChanlev.Global) {
     echo $color(info) -at *** Clear-Chanlev: There is no Q or L bot on $1 $+ .
+
    if (%ClearChanlev.Force == 0) {
 +
      echo -s ClearChanlev: ClearChanlev is currently running. If this is not the case, please use the -r flag (i.e. /clearchanlev -r #channel)
 +
      echo -s ClearChanlev: -----------------------------
 +
      return
 +
    }
 +
    else {
 +
      unset %ClearChanlev.Global
 +
      echo -s ClearChanlev: ClearChanlev reseted.
 +
    }
 +
  }
 +
  if (!%ClearChanlev.Channel) {
 +
     echo -s ClearChanlev: No channel specified.
 +
    return
 
   }
 
   }
   [[if-Then-Else|else]] {
+
   %r = $rand(1,1000)
    set %cc.what getlname
+
  set %ClearChanlev.Global %ClearChanlev.Channel %ClearChanlev.Complete %r
    set %cc.bot $iif(Q ison $1,Q,L)
+
  echo -s ClearChanlev: Now beginning to remove all chanlevs from channel %ClearChanlev.Channel $iif(%ClearChanlev.Complete, inclusive, except) yours!
    set %cc.chan $1
+
  echo -s ClearChanlev: Receiving own auth now!
    if ($2 == -remove) { [[set]] %cc.remove $true }
+
  .timerClearChanlevCleanUp 1 60 ClearChanlev.CleanUp
    else { [[set]] %cc.remove $false }
+
  .who $me n%nat, $+ %r
    echo $color(info) -at *** Clear-Chanlev: Getting your %cc.bot $+ -Account Name.
+
}
     .enable #clearchanlev
+
 
     .[[msg]] %cc.bot whois [[$me]]
+
raw 354:*: {
 +
  if ($2 == $gettok(%ClearChanlev.Global, 3, 32)) && ($3 == $me) {
 +
     haltdef
 +
     set %ClearChanlev.Global %ClearChanlev.Global $4
 
   }
 
   }
}
+
}
+
 
#[[Creating Groups|clearchanlev]] off
+
raw 315:*: {
+
   if (%ClearChanlev.Global) && ($2 == $me) {
[[On_notice|on ^*:NOTICE]]:*:*:{
+
    haltdef
   if ($nick == %cc.bot) {
+
    if ($gettok(%ClearChanlev.Global, 4, 32) == 0) {
     if (%cc.what == getlname) {
+
      echo -s ClearChanlev: You are NOT authed.
      if ($1 == $me) && ($3 == authed) {
+
      ClearChanlev.CleanUp
        set %cc.account $left($5,-1)
+
    }
 +
    else {
 +
      echo -s ClearChanlev: ...done.
 +
      set %ClearChanlev.Global %ClearChanlev.Global 0
 +
      .msg Q chanlev $gettok(%ClearChanlev.Global, 1, 32)
 +
    }
 +
  }
 +
}
 +
 
 +
alias -l ClearChanlev.GotMessages {
 +
  if (!$exists(ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt)) {
 +
     echo -s ClearChanlev: File does not exist!
 +
    ClearChanlev.CleanUp
 +
    return
 +
  }
 +
  if ($lines(ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt) == 0) {
 +
    echo -s ClearChanlev: No chanlev to remove!
 +
    ClearChanlev.CleanUp
 +
    return
 +
  }
 +
  if ($gettok(%ClearChanlev.Global, 5, 32) == 0) {
 +
    echo -s ClearChanlev: You are NOT owner of this channel. Aborting!
 +
    ClearChanlev.CleanUp
 +
    return
 +
  }
 +
  echo -s ClearChanlev: There are $lines(ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt) lines to send. This will take $&
 +
    approximatly $calc($lines(ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt) * $ClearChanlev.Delay / 1000) seconds. Removing...
 +
  .play Q ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt $ClearChanlev.Delay
 +
}
 +
 
 +
alias -l ClearChanlev.CleanUp {
 +
  .remove ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt
 +
  unset %ClearChanlev.*
 +
  .timerClearChanlevCleanUp off
 +
  echo -s ClearChanlev: Cleaned up!
 +
  echo -s ClearChanlev: -----------------------------
 +
}
 +
 
 +
; $1- = message from Q
 +
alias -l ClearChanlev.Interpret {
 +
  if (%ClearChanlev.Global) {
 +
    if (Username*Flags*Last join*Last changed iswm $1-) {
 +
      echo -s ClearChanlev: Saving chanlev now...
 +
      set %ClearChanlev.Global %ClearChanlev.Global 1
 +
    }
 +
    elseif (You do not have sufficient access on* iswm $1-) {
 +
      echo -s ClearChanlev: You do not have sufficied access on the specified channel!
 +
      ClearChanlev.CleanUp
 +
    }
 +
    elseif (End of list. == $1-) {  
 +
      echo -s ClearChanlev: ...done.
 +
      set %ClearChanlev.Global $puttok(%ClearChanlev.Global, 0, 6, 32)
 +
      if ($numtok(%ClearChanLev.Users,32)) {
 +
        write ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt REMOVEUSER $gettok(%ClearChanlev.Global, 1, 32) %ClearChanLev.Users
 +
        unset %ClearChanlev.Users
 
       }
 
       }
       if ($1- == End of list.) {
+
       ClearChanlev.GotMessages
        if (%cc.account) {
+
    }
          echo $color(info) -at *** Clear-Chanlev: Getting Userlist of %cc.chan $+ .
+
    elseif (Channel * is unknown or suspended. iswm $1-) {
          set %cc.what getchanlev
+
      echo -s ClearChanlev: Channel is not known or suspended. Aborting.
           .msg %cc.bot chanlev %cc.chan
+
      ClearChanlev.CleanUp
 +
    }
 +
    elseif ($gettok(%ClearChanlev.Global, 6, 32) == 1) {
 +
      if ($1 == $gettok(%ClearChanlev.Global, 4, 32)) {
 +
        if (n !isin $2) {
 +
          set %ClearChanlev.Global $puttok(%ClearChanlev.Global, 0, 5, 32)
 +
           return
 
         }
 
         }
 
         else {
 
         else {
           echo $color(info) -at *** Clear-Chanlev: You are not authed. Please auth before trying to clear a chanlev-list.
+
           set %ClearChanlev.Global $puttok(%ClearChanlev.Global, 1, 5, 32)
          unset %cc.*
 
          .[[disable]] #clearchanlev
 
 
         }
 
         }
      }
+
 
    }
+
         if ($gettok(%ClearChanlev.Global, 2, 32) == 0) {
    elseif (%cc.what == getchanlev) {
+
           return
    if ($1 != %cc.account) && (End of* !iswm $1-) && (Users for channel* !iswm $1-) && (Authname* !iswm $1-) && ($1- != $str(-,29)) && $&
 
        ($1 != Channeltype:) && (Known users* !iswm $1-) {
 
         if (n !isin $iif(%cc.bot == Q,$3,$2)) {
 
           [[write]] clearchanlev.txt CHANLEV %cc.chan # [ $+ [ $1 ] ] $iif(%cc.bot == Q,-amotv,-amovg)
 
 
         }
 
         }
         elseif (n isin $iif(%cc.bot == Q,$3,$2)) {
+
         else {
           set %cc.noremove $true
+
          write ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt CHANLEV $gettok(%ClearChanlev.Global, 1, 32) $chr(35) $+ $1 $replace($2,+,-)
 +
           return
 
         }
 
         }
 
       }
 
       }
       elseif ($1 == %cc.account) && (n !isin [[$iif]](%cc.bot == Q,$3,$2)) {
+
       else {
        .[[remove]] "clearchanlev.txt"
+
        if (n isin $2) {
        [[unset]] %cc.*
+
          write ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt CHANLEV $gettok(%ClearChanlev.Global, 1, 32) $chr(35) $+ $1 $replace($2,+,-)
        .disable #clearchanlev
+
         }
        echo $color(info) -at *** Clear-Chanlev: You are not the owner of that channel. Halting...
+
        else {
      }
+
           set %ClearChanlev.Users $addtok(%ClearChanLev.users,$chr(35) $+ $1,32)
      elseif (End* [[If-Then-Else#The_Operators|iswm]] $1-) {
+
          if ($numtok(%ClearChanlev.Users,32) == 18) {
         if (%cc.remove) {
+
             write ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt REMOVEUSER $gettok(%ClearChanlev.Global, 1, 32) %ClearChanlev.Users
           if (%cc.noremove) {
+
            unset %ClearChanlev.Users
            echo $color(info) -at *** Clear-Chanlev: You may not remove %cc.bot $+ . You are not the only owner on %cc.chan $+ .
 
            .remove "clearchanlev.txt"
 
            unset %cc.*
 
            .disable #clearchanlev
 
            [[halt]]
 
          }
 
          else {
 
             write clearchanlev.txt CHANLEV %cc.chan # [ $+ [ %cc.account ] ] $iif(%cc.bot == Q,-amnotv,-amnovg)
 
 
           }
 
           }
 
         }
 
         }
        set %cc.what removeusers
 
        echo $color(info) -at *** Clear-Chanlev: There are $lines(clearchanlev.txt) Users to remove. It will take about $&
 
          [[$calc]]([[$lines]](clearchanlev.txt)*2) seconds. Removing...
 
        .[[play]] %cc.bot clearchanlev.txt 2000
 
 
       }
 
       }
 
     }
 
     }
    [[haltdef]]
 
 
   }
 
   }
}
+
}
+
 
[[On_playend|on *:PLAYEND]]:{
+
on ^*:Notice:*:?: {
   if ([[$nopath]]([[$filename]]) == clearchanlev.txt) {
+
   if ($nick == Q) && (%ClearChanlev.Global) {
     echo $color(info) -at *** Clear-Chanlev: Successfully Removed $iif(%cc.remove,$iif(%cc.bot == Q,Q,L) from,all Non-Owners on) %cc.chan $+ .
+
     haltdef
    if (!%cc.remove) { .msg %cc.bot chanlev %cc.chan }
+
    ClearChanlev.Interpret $1-
    unset %cc.*
+
  }
     .remove "clearchanlev.txt"
+
}
     .disable #clearchanlev
+
 
 +
on ^*:Text:*:?: {
 +
  if ($nick == Q) && (%ClearChanlev.Global) {
 +
     haltdef
 +
     ClearChanlev.Interpret $1-
 
   }
 
   }
}
+
}
 
#clearchanlev end
 
  
 +
on *:PLAYEND:{
 +
  if ($nopath($filename) == ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt) {
 +
    echo -s ClearChanlev: ...done.
 +
    ClearChanlev.Cleanup
 +
  }
 +
}
 
[[Category:Script Archive]]
 
[[Category:Script Archive]]
{{Author|Kickchon}}
+
{{Author|Doomie}}

Revision as of 19:25, 3 April 2008

ClearChanlev script by doomie
#help.script @ QuakeNet
You can use this script by typing
/clearchanlev [-c|-r] #channel
Note, that you must be authed and owner of #channel.
Flags
* -r ... Resets the script, i.e. cleans everything up. One usually doesn't need that flag, however, if something didn't work,
one can use it.
* -c ... If you use this flag, the script will remove you from the channel aswell. This means, that Q will leave the channel
completly. Note that you can _NOT_ reverse it!
Example output
ClearChanlev
-----------------------------
ClearChanlev
Now beginning to remove all chanlevs from channel #channel except yours!
ClearChanlev
Receiving own auth now!
ClearChanlev
...done.
ClearChanlev
Saving chanlev now...
ClearChanlev
...done.
ClearChanlev
There are 2 lines to send. This will take approximatly 4 seconds. Removing...
ClearChanlev
...done.
ClearChanlev
Cleaned up!
ClearChanlev
-----------------------------
Returns the milliseconds between every message sent to Q
If you excess flood, you should increase this value to 4000 or even 5000.

alias -l ClearChanlev.Delay { return 3000 }

$1 = #channel
flags
-c --complete = deletes the complete chanlev, inclusive owner. This will
result in Q parting.
-r --reset = resets the scripts in case something didn't work the last time.

alias ClearChanlev {

 echo -s ClearChanlev: -----------------------------
 var %i = 1, %c, %ClearChanlev.Complete = 0, %r, %ClearChanlev.Force = 0, %ClearChanlev.Channel
 while (%i <= $0) {
   %c = $ [ $+ [ %i ] ]
   if (%c == -c) || (%c == --complete) {
     %ClearChanlev.Complete = 1
   }
   elseif (%c == -r) || (%c == --reset) {
     %ClearChanlev.Force = 1
   }
   elseif ($left(%c, 1) == $chr(35)) {
     %ClearChanlev.Channel = %c
   }
   inc %i
 }
 if (%ClearChanlev.Global) {
   if (%ClearChanlev.Force == 0) {
     echo -s ClearChanlev: ClearChanlev is currently running. If this is not the case, please use the -r flag (i.e. /clearchanlev -r #channel)
     echo -s ClearChanlev: -----------------------------
     return
   }
   else {
     unset %ClearChanlev.Global
     echo -s ClearChanlev: ClearChanlev reseted.
   }
 }
 if (!%ClearChanlev.Channel) {
   echo -s ClearChanlev: No channel specified.
   return
 }
 %r = $rand(1,1000)
 set %ClearChanlev.Global %ClearChanlev.Channel %ClearChanlev.Complete %r
 echo -s ClearChanlev: Now beginning to remove all chanlevs from channel %ClearChanlev.Channel $iif(%ClearChanlev.Complete, inclusive, except) yours!
 echo -s ClearChanlev: Receiving own auth now!
 .timerClearChanlevCleanUp 1 60 ClearChanlev.CleanUp
 .who $me n%nat, $+ %r

}

raw 354:*: {

 if ($2 == $gettok(%ClearChanlev.Global, 3, 32)) && ($3 == $me) {
   haltdef
   set %ClearChanlev.Global %ClearChanlev.Global $4
 }

}

raw 315:*: {

 if (%ClearChanlev.Global) && ($2 == $me) {
   haltdef
   if ($gettok(%ClearChanlev.Global, 4, 32) == 0) {
     echo -s ClearChanlev: You are NOT authed.
     ClearChanlev.CleanUp
   } 
   else {
     echo -s ClearChanlev: ...done.
     set %ClearChanlev.Global %ClearChanlev.Global 0
     .msg Q chanlev $gettok(%ClearChanlev.Global, 1, 32)
   }
 }

}

alias -l ClearChanlev.GotMessages {

 if (!$exists(ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt)) {
   echo -s ClearChanlev: File does not exist!
   ClearChanlev.CleanUp
   return
 }
 if ($lines(ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt) == 0) {
   echo -s ClearChanlev: No chanlev to remove!
   ClearChanlev.CleanUp
   return
 }
 if ($gettok(%ClearChanlev.Global, 5, 32) == 0) {
   echo -s ClearChanlev: You are NOT owner of this channel. Aborting!
   ClearChanlev.CleanUp
   return
 }
 echo -s ClearChanlev: There are $lines(ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt) lines to send. This will take $&
   approximatly $calc($lines(ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt) * $ClearChanlev.Delay / 1000) seconds. Removing... 
 .play Q ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt $ClearChanlev.Delay

}

alias -l ClearChanlev.CleanUp {

 .remove ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt
 unset %ClearChanlev.*
 .timerClearChanlevCleanUp off
 echo -s ClearChanlev: Cleaned up!
 echo -s ClearChanlev: -----------------------------

}

$1- = message from Q

alias -l ClearChanlev.Interpret {

 if (%ClearChanlev.Global) {
   if (Username*Flags*Last join*Last changed iswm $1-) {
     echo -s ClearChanlev: Saving chanlev now...
     set %ClearChanlev.Global %ClearChanlev.Global 1
   }
   elseif (You do not have sufficient access on* iswm $1-) {
     echo -s ClearChanlev: You do not have sufficied access on the specified channel!
     ClearChanlev.CleanUp
   }
   elseif (End of list. == $1-) { 
     echo -s ClearChanlev: ...done.
     set %ClearChanlev.Global $puttok(%ClearChanlev.Global, 0, 6, 32)
     if ($numtok(%ClearChanLev.Users,32)) {
       write ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt REMOVEUSER $gettok(%ClearChanlev.Global, 1, 32) %ClearChanLev.Users
       unset %ClearChanlev.Users
     }
     ClearChanlev.GotMessages
   }
   elseif (Channel * is unknown or suspended. iswm $1-) {
     echo -s ClearChanlev: Channel is not known or suspended. Aborting.
     ClearChanlev.CleanUp
   }
   elseif ($gettok(%ClearChanlev.Global, 6, 32) == 1) {
     if ($1 == $gettok(%ClearChanlev.Global, 4, 32)) {
       if (n !isin $2) {
         set %ClearChanlev.Global $puttok(%ClearChanlev.Global, 0, 5, 32)
         return
       }
       else {
         set %ClearChanlev.Global $puttok(%ClearChanlev.Global, 1, 5, 32)
       }
       if ($gettok(%ClearChanlev.Global, 2, 32) == 0) {
         return
       }
       else {
         write ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt CHANLEV $gettok(%ClearChanlev.Global, 1, 32) $chr(35) $+ $1 $replace($2,+,-)
         return
       }
     }
     else {
       if (n isin $2) {
         write ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt CHANLEV $gettok(%ClearChanlev.Global, 1, 32) $chr(35) $+ $1 $replace($2,+,-)
       }
       else {
         set %ClearChanlev.Users $addtok(%ClearChanLev.users,$chr(35) $+ $1,32)
         if ($numtok(%ClearChanlev.Users,32) == 18) {
           write ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt REMOVEUSER $gettok(%ClearChanlev.Global, 1, 32) %ClearChanlev.Users
           unset %ClearChanlev.Users
         }
       }
     }
   }
 }

}

on ^*:Notice:*:?: {

 if ($nick == Q) && (%ClearChanlev.Global) {
   haltdef
   ClearChanlev.Interpret $1-
 }

}

on ^*:Text:*:?: {

 if ($nick == Q) && (%ClearChanlev.Global) {
   haltdef
   ClearChanlev.Interpret $1-
 }

}

on *:PLAYEND:{

 if ($nopath($filename) == ClearChanlev $+ $gettok(%ClearChanlev.Global, 3, 32) $+ .txt) {
   echo -s ClearChanlev: ...done.
   ClearChanlev.Cleanup
 }

}

Contributed by Doomie