View difference between Paste ID: pmKummFa and Q2WQJLkk
SHOW: | | - or go back to the newest paste.
1
proc delop_pub {nick uhost hand chan text} {
2
	global globflags chanflags
3-
	if {![matchattr [nick2hand $nick] $globflags]} {
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-
	if {![matchattr $handle |$chanflags $chan]} {
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-
	set hasop 0
21+
	} else {
22-
	foreach other [channels] {
22+
23-
		if {[matchattr $handle |$chanflags $other]} {
23+
24-
			set hasop 1
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-
	if {$hasmaster && $hasop} {
29+
		
30-
		chattr $target |-o $chan
30+
		set hasanyop 0
31
		foreach other [channels] {
32
			if {[string equal -nocase $chan $other]} {
33
				continue
34-
	if {!$hasmaster && !$hasop} {
34+
			}
35-
		deluser $target
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
}