-
Notifications
You must be signed in to change notification settings - Fork 0
/
access.etcl
executable file
·311 lines (306 loc) · 12.4 KB
/
access.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
###
# Usage: /msg botnick access [<channel>] [<wildcard match> <-online> <-userhost> <-lm> <-ls> <-host match> <-min level> <-max level>]
# Usage: .access <#channel> [<wildcard match> <-online> <-userhost> <-lm> <-ls> <-host match> <-min level> <-max level>]
###
### ACCESS:
bind msg - access "msg_error msg_access"
bind pub - $set(cmd)access "pub_error pub_access"
bind dcc - access "dcc_error dcc_access"
### CHANNEL:
proc pub_access {nick uhost handle chan text} {
if {[validuser $handle]} {
all_access c $nick $uhost $handle $chan $text
}
}
### QUERY:
proc msg_access {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_access m $nick $uhost $handle [lindex $text 0] [lrange $text 1 end]
}
}
### MAIN:
proc all_access {type nick uhost handle chan text} {
global set botnick
chan_settings access $type $nick $uhost $handle $chan $text
if {[level $handle $chan] == "0" || [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 access]} {
notice $nick $handle "Your level of [level $handle $chan] is less then the required [comget $chan access] for this command"
} else {
if {$text == ""} {
set text "-check $nick"
}
set ma ""
set mn ""
set mx ""
set ho ""
set on 0
set uh 0
set lm 0
set ls 0
set cn 0
while {[lindex $text $cn] != ""} {
set w [string tolower [lindex $text $cn]]
set wd [string tolower [lindex $text [expr $cn + 1]]]
if {$w == "-lm"} {
set lm 1
incr cn 1
} elseif {$w == "-ls"} {
set ls 1
incr cn 1
} elseif {[letters $w 3 1] == "-us" && [string length $w] <= "9"} {
set uh 1
incr cn 1
} elseif {[letters $w 3 1] == "-on" && [string length $w] <= "7"} {
set on 1
incr cn 1
} elseif {[letters $w 3 1] == "-ho" && [string length $w] <= "5"} {
set ho $wd
incr cn 2
} elseif {[letters $w 3 1] == "-mi" && [string length $w] <= "4" && [isnum $wd]} {
set mn $wd
incr cn 2
} elseif {[letters $w 3 1] == "-ma" && [string length $w] <= "4" && [isnum $wd]} {
set mx $wd
incr cn 2
} elseif {![string match -* $w]} {
set ma "$ma [lindex $text $cn]"
incr cn 1
} else {
incr cn 1
}
}
if {$ma != ""} {
set ma [lindex $ma 0]
} elseif {$ma == ""} {
set ma *
}
if {$mn > "200" || $mn < "0" || $mn == ""} {
set mn 0
}
if {$mx > "200" || $mx < "0" || $mx == ""} {
set mx 200
}
if {$ho == ""} {
set ho *
}
if {[string tolower [lindex $text 0]] == "-check" && [lindex $text 1] == ""} {
notice $nick $handle "Invalid request: Which online client?"
return
} elseif {[string tolower [lindex $text 0]] == "-check" && [getchanhost [lindex $text 1]] == ""} {
notice $nick $handle "I cannot tell if [lindex $text 1] is currently online"
return
} elseif {[string tolower [lindex $text 0]] == "-check"} {
set ma [nick2hand [lindex $text 1]]
}
if {[string tolower [lindex $text 0]] == "-check"} {
notice $nick $handle "\002***\002 Channel membership list for [lindex $text 1] on $chan \002***\002"
} else {
notice $nick $handle "\002***\002 $chan Database \[Match(Nick: [lindex $ma 0] Userhost: $ho) Min: [align $mn 3] Max: [align $mx 3]\] \002***\002"
}
notice $nick $handle "\002 \002 NickName Level AOP AOV Prot\002"
if {[string tolower [lindex $text 0]] == "-check" && [string tolower [lindex $text 1]] == [string tolower $set(chanserv)]} {
notice $nick $handle "$set(chanserv) doesn't need no access >:)"
} elseif {[string tolower [lindex $text 0]] == "-check" && [level $ma $chan] > "0"} {
notice $nick $handle "\0021 \002 [align $ma 17] [align [level $ma $chan] 6] [align [change [aop $ma $chan] yesno] 5] [align [change [aov $ma $chan] yesno] 5] [align [change [protect $ma $chan] yesno] 5]"
if {[suspend $handle $chan]} {
notice $nick $handle "Suspend Expires: [ctime [lindex [suspendinfo $chan $handle] 0]] $set(timezone)"
notice $nick $handle " Suspend Reason: [getuser $handle xtra suspendr($chan)]"
}
} elseif {[string tolower [lindex $text 0]] == "-check" && [level $ma $chan] == "0"} {
notice $nick $handle "[lindex $text 1] does not have access to $chan"
} else {
set cn 1
set cn2 0
set er 0
foreach n [access $chan] {
if {[level $handle $chan] < [lindex [changet $chan accessall] 0] && $cn2 > [lindex [changet $chan accessall] 1] && $er} {
continue
} elseif {[level $handle $chan] < [lindex [changet $chan accessall] 0] && $cn2 > [lindex [changet $chan accessall] 1] && !$er} {
notice $nick $handle "Your level of [level $handle $chan] only enables you to list [lindex [changet $chan accessall] 1] users"
set er 1
} elseif {[string match [string tolower $ma] [string tolower $n]] && [string match [string tolower $ho] [string tolower [nickinfo $n userhost]]] && [level $n $chan] >= $mn && [level $n $chan] <= $mx} {
if {$uh} {
set uha [nickinfo $n userhost]
} else {
set uha ""
}
if {$on && [notify $n]} {
set ona \[Online\]
} elseif {$on && ![notify $n]} {
set ona \[Offline\]
} else {
set ona ""
}
notice $nick $handle "\002[align $cn 5]\002 [align $n 17] [align [level $n $chan] 6] [align [change [aop $n $chan] yesno] 5] [align [change [aov $n $chan] yesno] 5] [align [change [protect $n $chan] yesno] 5]$uha $ona"
if {[suspend $n $chan]} {
notice $nick $handle "Suspend Expires: [ctime [lindex [suspendinfo $chan $n] 0]] $set(timezone)"
notice $nick $handle " Suspend Reason: [getuser $n xtra suspendr($chan)]"
}
if {$ls} {
notice $nick $handle " LS [ctime [lastseen $n $chan]] $set(timezone)"
}
if {$lm} {
notice $nick $handle " LM \[[lindex [lastmod $n $chan] 1]\] [lindex [lastmod $n $chan] 2] ([ctime [lindex [lastmod $n $chan] 0]] $set(timezone))"
}
incr cn2 1
}
incr cn 1
}
if {$cn2 == "0"} {
notice $nick $handle "There were no matches for your selected criteria"
}
}
notice $nick $handle "\002***\002 End of List \002***\002"
putcmdlog "> !$handle! ($nick!$uhost) ACCESS\[$type\] ($chan): $text"
}
}
### DCC:
proc dcc_access {handle idx text} {
global set botnick
if {$text == ""} {
putdcc $idx "> Usage: access <#channel> \[<wildcard match> <-host> <-userhost> <-lm> <-ls> <-min level> <-max level>\]"
return
}
set chan [lindex $text 0]
set text [lrange $text 1 end]
if {[lindex [lindex [findidx $idx] 4] 1] != "socket_command"} {
putcmdlog "> #$handle# ACCESS ($chan) $text"
} else {
putcmdlog "> #$handle ([lindex [replace [findidx $idx] @ " "] 3])# ACCESS ($chan) $text"
}
if {![validchan $chan]} {
putdcc $idx "> Invalid channel."
} else {
if {$text == "" && [hand2nick $handle] == ""} {
putdcc $idx "> Sorry, I cannot find you on IRC.. who are you?"
return
} elseif {$text == ""} {
set text "-check $handle"
}
set ma ""
set mn ""
set mx ""
set ho ""
set on 0
set uh 0
set lm 0
set ls 0
set cn 0
while {[lindex $text $cn] != ""} {
set w [string tolower [lindex $text $cn]]
set wd [string tolower [lindex $text [expr $cn + 1]]]
if {$w == "-lm"} {
set lm 1
incr cn 1
} elseif {$w == "-ls"} {
set ls 1
incr cn 1
} elseif {[letters $w 3 1] == "-us" && [string length $w] <= "9"} {
set uh 1
incr cn 1
} elseif {[letters $w 3 1] == "-on" && [string length $w] <= "7"} {
set on 1
incr cn 1
} elseif {[letters $w 3 1] == "-ho" && [string length $w] <= "5"} {
set ho $wd
incr cn 2
} elseif {[letters $w 3 1] == "-mi" && [string length $w] <= "4" && [isnum $wd]} {
set mn $wd
incr cn 2
} elseif {[letters $w 3 1] == "-ma" && [string length $w] <= "4" && [isnum $wd]} {
set mx $wd
incr cn 2
} elseif {![string match -* $w]} {
set ma "$ma [lindex $text $cn]"
incr cn 1
} else {
incr cn 1
}
}
if {$ma != ""} {
set ma [lindex $ma 0]
} elseif {$ma == ""} {
set ma *
}
if {$mn > "200" || $mn < "0" || $mn == ""} {
set mn 0
}
if {$mx > "200" || $mx < "0" || $mx == ""} {
set mx 200
}
if {$ho == ""} {
set ho *
}
if {[string tolower [lindex $text 0]] == "-check" && [lindex $text 1] == ""} {
putdcc $idx "Invalid request: Which online client?"
return
} elseif {[string tolower [lindex $text 0]] == "-check" && [getchanhost [hand2nick [lindex $text 1]]] == ""} {
putdcc $idx "I cannot tell if [lindex $text 1] is currently online"
return
} elseif {[string tolower [lindex $text 0]] == "-check"} {
set ma [lindex $text 1]
}
if {[string tolower [lindex $text 0]] == "-check"} {
putdcc $idx "\002***\002 Channel membership list for [lindex $text 1] on $chan \002***\002"
} else {
putdcc $idx "\002***\002 $chan Database \[Match(Nick: [lindex $ma 0] Userhost: $ho) Min: [align $mn 3] Max: [align $mx 3]\] \002***\002"
}
putdcc $idx "\002 \002 NickName Level AOP AOV Prot\002"
if {[string tolower [lindex $text 0]] == "-check" && [level $ma $chan] > "0"} {
putdcc $idx "\0021 \002 [align $ma 17] [align [level $ma $chan] 6] [align [change [aop $ma $chan] yesno] 5] [align [change [aov $ma $chan] yesno] 5] [align [change [protect $ma $chan] yesno] 5]"
if {[suspend $handle $chan]} {
putdcc $idx "Suspend Expires: [ctime [lindex [suspendinfo $chan $handle] 0]] $set(timezone)"
putdcc $idx " Suspend Reason: [getuser $handle xtra suspendr($chan)]"
}
} elseif {[string tolower [lindex $text 0]] == "-check" && [level $ma $chan] == "0"} {
putdcc $idx "[lindex $text 1] does not have access to $chan"
} else {
set cn 1
set cn2 0
foreach n [access $chan] {
if {[string match [string tolower $ma] [string tolower $n]] && [string match [string tolower $ho] [string tolower [nickinfo $n userhost]]] && [level $n $chan] >= $mn && [level $n $chan] <= $mx} {
if {$uh} {
set uha [nickinfo $n userhost]
} else {
set uha ""
}
if {$on && [notify $n]} {
set ona \[Online\]
} elseif {$on && ![notify $n]} {
set ona \[Offline\]
} else {
set ona ""
}
putdcc $idx "\002[align $cn 5]\002 [align $n 17] [align [level $n $chan] 6] [align [change [aop $n $chan] yesno] 5] [align [change [aov $n $chan] yesno] 5] [align [change [protect $n $chan] yesno] 5]$uha $ona"
if {[suspend $n $chan]} {
putdcc $idx "Suspend Expires: [ctime [lindex [suspendinfo $chan $n] 0]] $set(timezone)"
putdcc $idx " Suspend Reason: [getuser $n xtra suspendr($chan)]"
}
if {$ls} {
putdcc $idx " LS [ctime [lastseen $n $chan]] $set(timezone)"
}
if {$lm} {
putdcc $idx " LM \[[lindex [lastmod $n $chan] 1]\] [lindex [lastmod $n $chan] 2] ([ctime [lindex [lastmod $n $chan] 0]] $set(timezone))"
}
incr cn2 1
}
incr cn 1
}
if {$cn2 == "0"} {
putdcc $idx "There were no matches for your selected criteria"
}
}
putdcc $idx "\002***\002 End of List \002***\002"
}
}