-
Notifications
You must be signed in to change notification settings - Fork 0
/
unban.etcl
executable file
·134 lines (130 loc) · 5.33 KB
/
unban.etcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
###
# Usage: /msg botnick unban [<channel>] <nickname|hostname|all|perms|sticky|me>
###
### UNBAN:
bind msg - unban "msg_error msg_unban"
bind pub - $set(cmd)unban "pub_error pub_unban"
### CHANNEL:
proc pub_unban {nick uhost handle chan text} {
if {[validuser $handle]} {
all_unban c $nick $uhost $handle $chan $text
}
}
### QUERY:
proc msg_unban {nick uhost handle text} {
if {![validuser $handle]} {
return
} elseif {[lindex $text 0] == ""} {
notice $nick $handle "Invalid request: Wheres the channel name?"
} elseif {![string match #* [lindex $text 0]]} {
notice $nick $handle "Invalid request: [lindex $text 0] is not a channel"
} else {
all_unban m $nick $uhost $handle [lindex $text 0] [lrange $text 1 end]
}
}
### MAIN:
proc all_unban {type nick uhost handle chan text} {
global set botnick
chan_settings unban $type $nick $uhost $handle $chan $text
if {[level $handle $chan] == "0" || ![auth_check $nick $uhost $handle $chan] || [backup_check $chan]} {
return
} elseif {![validchan $chan]} {
notice $nick $handle "Invalid request: $chan is not a valid channel"
} elseif {[string tolower $type] == "c" && [changet $chan nochanmsg]} {
notice $nick $handle "$set(cmd)commands have been disabled for $chan"
} elseif {[level $handle $chan] < [comget $chan unban]} {
notice $nick $handle "Your level of [level $handle $chan] is less then the required [comget $chan unban] for this command"
} elseif {[lindex $text 0] == ""} {
notice $nick $handle "Invalid request: Unban what?"
} elseif {[string tolower [lindex $text 0]] == "all"} {
set b 0
foreach ban [chanbans $chan] {
if {![isban [lindex $ban 0] $chan]} {
pushmode $chan -b [lindex $ban 0]
}
}
foreach ban [banlist $chan] {
set rn [lindex $ban 1]
if {[lindex $rn 0] <= [level $handle $chan] && [lindex $ban 2] != "0"} {
killchanban $chan [lindex $ban 0]
checkusers
setuser &banlist& XTRA $chan,[lindex $ban 0]
incr b 1
} elseif {[ischanban [lindex $ban 0] $chan]} {
pushmode $chan -b [lindex $ban 0]
}
}
notice $nick $handle "Finished parsing banlist for $chan \[$b bans removed\]"
} elseif {[string tolower [lindex $text 0]] == "perms"} {
set b 0
foreach ban [chanbans $chan] {
if {![isban [lindex $ban 0] $chan]} {
pushmode $chan -b [lindex $ban 0]
}
}
foreach ban [banlist $chan] {
set rn [lindex $ban 1]
if {[lindex $rn 0] <= [level $handle $chan] && [lindex $ban 2] == "0"} {
killchanban $chan [lindex $ban 0]
checkusers
setuser &banlist& XTRA $chan,[lindex $ban 0]
incr b 1
} elseif {[ischanban [lindex $ban 0] $chan]} {
pushmode $chan -b [lindex $ban 0]
}
}
notice $nick $handle "Finished parsing banlist for $chan \[$b bans removed\]"
} elseif {[string tolower [lindex $text 0]] == "sticky"} {
set b 0
foreach ban [chanbans $chan] {
if {![isban [lindex $ban 0] $chan]} {
pushmode $chan -b [lindex $ban 0]
}
}
foreach ban [banlist $chan] {
set rn [lindex $ban 1]
if {[lindex $rn 0] <= [level $handle $chan] && [isbansticky [lindex $ban 0] $chan]} {
killchanban $chan [lindex $ban 0]
checkusers
setuser &banlist& XTRA $chan,[lindex $ban 0]
incr b 1
} elseif {[ischanban [lindex $ban 0] $chan]} {
pushmode $chan -b [lindex $ban 0]
}
}
notice $nick $handle "Finished parsing banlist for $chan \[$b bans removed\]"
} elseif {[string tolower [lindex $text 0]] == "me"} {
set b 0
foreach ban "[banlist $chan] [chanbans $chan]" {
set rn [lindex $ban 1]
if {[lindex $rn 0] <= [level $handle $chan] && [string match [string tolower [lindex $ban 0]] [string tolower $nick!$uhost]]} {
killchanban $chan [lindex $ban 0]
checkusers
setuser &banlist& XTRA $chan,[lindex $ban 0]
incr b 1
} elseif {[ischanban [lindex $ban 0] $chan] && [string match [string tolower [lindex $ban 0]] [string tolower $nick!$uhost]]} {
pushmode $chan -b [lindex $ban 0]
incr b 1
}
}
notice $nick $handle "Finished parsing banlist for $chan \[$b bans removed\]"
} else {
foreach ban "[banlist $chan] [chanbans $chan]" {
set rn [lindex $ban 1]
if {[lindex $rn 0] <= [level $handle $chan] && [string tolower [lindex $ban 0]] == [string tolower [getstring [lindex $text 0]]]} {
killchanban $chan [lindex $ban 0]
checkusers
setuser &banlist& XTRA $chan,[lindex $ban 0]
notice $nick $handle "Ban \002[lindex $ban 0]\002 removed on $chan"
}
if {[isnum [lindex $rn 0]] && [lindex $rn 0] > [level $handle $chan] && [string tolower [lindex $ban 0]] == [string tolower [getstring [lindex $text 0]]]} {
notice $nick $handle "Ban \002[lindex $ban 0]\002 requires level [lindex $rn 0] or higher to remove"
}
if {[string tolower [lindex $ban 0]] == [string tolower [getstring [lindex $text 0]]] && [ischanban [lindex $ban 0] $chan]} {
pushmode $chan -b [lindex $ban 0]
}
}
notice $nick $handle "Finished parsing banlist for $chan"
}
putcmdlog "> !$handle! ($nick!$uhost) UNBAN\[$type\] ($chan): $text"
}