Advertisement
Guest User

Untitled

a guest
Jan 4th, 2019
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. proc delop_pub {nick uhost hand chan text} {
  2.     global globflags chanflags
  3.     if {![matchattr $hand $globflags]} {
  4.         putserv "PRIVMSG $chan :Error! You don't have access to this script ${nick}!"
  5.         return
  6.     }
  7.    
  8.     set target [lindex [split $text] 0]
  9.     set handle [nick2hand $target]
  10.    
  11.     if {![validuser $handle]} {
  12.         putserv "PRIVMSG $chan :Error! $target doesn't exist in my database"
  13.         return
  14.     }
  15.  
  16.     set hasop [matchattr $handle |$chanflags $chan]
  17.     if {$hasop} {
  18.         # removed the chan flag from the user in the specified chan
  19.         chattr $handle |-$chanflags $chan
  20.         putlog "$target (handle: $handle) lost his +$chanflag in $chan"
  21.     } else {
  22.         putserv "PRIVMSG $chan :Error! $target is not OP on $chan"
  23.         return
  24.     }
  25.  
  26.     set hasmaster [matchattr $handle $globflags]
  27.     if {!$hasmaster} {
  28.         # deletes the user if he has no global flags and no other chan flags in other channel
  29.        
  30.         set hasanyop 0
  31.         foreach other [channels] {
  32.             if {[string equal -nocase $chan $other]} {
  33.                 continue
  34.             }
  35.            
  36.             if {[matchattr $handle |$chanflags $other]} {
  37.                 set hasanyop 1
  38.                 break
  39.             }
  40.         }
  41.        
  42.         if {!$hasanyop} {
  43.             deluser $target
  44.             putlog "$target was successfully deleted from my user database"
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement