-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvoiceallbut.tcl
386 lines (349 loc) · 17.4 KB
/
voiceallbut.tcl
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# Script : VoiceAllBut by David Proper (Dr. Nibble [DrN])
# New Stuff by : siniStar (Austin Ellis) @ irc.IRC4Fun.net
#
# Description : VoiceAllBut is an auto-voice script with an exceptions
# list. You can add/remove people from the no-voice list
# via a channel command. VAB will voice all users who
# join except users on the no-voice list.
# Good for botchannels who are +m and want the talker
# bots to just shut up. :)
#
# History : 02/10/2002 - First Release
# 03/25/2002 - v1.01
# o Modified sitemask definition to make a
# more normal mask. (Instead of full domain)
# o Will now de-voice user if they are voiced
# when added to the novoice list and voice
# them when removed. (Suggested by UTAKER)
# 06/21/2002 - v1.02
# o Added subst command to see if that'd help
# with nicks using | and shit.
# o Added list of channels to voice on.
# (Requested by UTAKER@DALnet)
# o Added public commands to add/del/list VAB
# channel list.
# o Saves channel list to datafile. Will only
# use VAB(chans) list if no datafile is found
# 03/30/2017 - v1.50 and onward:
# o See GitHub (https://github.com/IRC4Fun/voiceallbut)
# for new updates & commits. (v1.03-v2.0+)
#
#
# Future Plans : Fix Bugs. :)
# o Only active on defined channels
#
# Commands Added:
# Where F CMD F CMD F CMD F CMD
# ------- - ---------- - ------------ - ----------- - ----------
# Public: o vab o vablist o vabadd o vabdel
# MSG: N/A
# DCC: N/A
#
# This is the user-definable flag to use to indicate a user on the no-voice list
set VAB(flag) V
# Default flags to give when adding a new user
set VAB(default-flags) "+h-p"
# User access required to modify/list no-voice list.
set VAB(access) "o|o"
# Define this as the channels you want to protect. * for all
set VAB(chans) "#Channel"
# Define this as the file to store dynamic list of channels to voice on
set VAB(datafile) "vablist.dat"
# Trigger charactor to use.
set cmdchar_ "*"
set VAB(ver) "v2.5.1"
proc cmdchar { } {global cmdchar_; return $cmdchar_}
bind join - ** VAB_join
proc VAB_join {nick uhost hand chan} {
global VAB
if {![voicechan $chan]} {return 1}
if {([matchchanattr $hand |$VAB(flag) $chan])} {return 0}
pushmode $chan +v $nick
}
bind pub $VAB(access) [cmdchar]vab pub_vab
proc pub_vab {nick uhost hand chan rest} {
global VAB
subst -nobackslashes -nocommands -novariables rest
if {$rest == ""} {
putserv "NOTICE $nick :Calling Syntax: [cmdchar]vab cmd \[nick\]"
putserv "NOTICE $nick : Commands: list - Lists no-voice users"
putserv "NOTICE $nick : add nick - Add nick to novoice list"
putserv "NOTICE $nick : del nick - Remove nick from novoice list"
return 0
}
set cmd [string toupper [lindex $rest 0]]
set rest [lrange $rest 1 end]
switch $cmd {
"LIST" {vab_listuser $nick $uhost $hand $chan $rest}
"ADD" {vab_adduser $nick $uhost $hand $chan $rest}
"DEL" {vab_deluser $nick $uhost $hand $chan $rest}
}
}
bind msg $VAB(access) vab msg_vab
proc msg_vab {nick uhost hand rest} {
global VAB
subst -nobackslashes -nocommands -novariables rest
if {$rest == ""} {
putserv "NOTICE $nick :Calling Syntax: vab <channel> cmd <nick>"
putserv "NOTICE $nick : Commands: list - Lists no-voice users"
putserv "NOTICE $nick : add nick - Add nick to no-voice list"
putserv "NOTICE $nick : del nick - Remove nick from no-voice list"
return 0
}
set cmd [string toupper [lindex $rest 1]]
set chan [lindex $rest 0]
if {$chan == "#" || $chan == ""} {putquick "NOTICE $nick :SYNTAX: /msg $botnick VAB <#channel> <cmd> <nickname>" ; return 0}
if {![string match "#*" $chan]} {set chan "#$chan"}
if {![validchan $chan]} {putquick "NOTICE $nick :ERROR: I am not on channel: $chan." ; return 0}
set rest [lrange $rest 2 end]
switch $cmd {
"LIST" {vab_listuser $nick $uhost $hand $chan $rest}
"ADD" {vab_adduser $nick $uhost $hand $chan $rest}
"DEL" {vab_deluser $nick $uhost $hand $chan $rest}
}
}
proc vab_adduser {nick uhost hand chan rest} {
global VAB
subst -nobackslashes -nocommands -novariables rest
if {$rest == ""} {putserv "NOTICE $nick :Calling Syntax: [cmdchar]vab add nick"; return 0}
set user [lindex $rest 0]
if {![onchan $user $chan]} {set thand $user} else {set thand [nick2hand $user]}
if {![validuser $thand]} {
if {![onchan $user $chan]} {putserv "NOTICE $nick :$user is not on $chan. Can't get a hostmask to add as new user."; return 0}
if {$thand == "*"} {set thand $user}
set sitemask "*!*[string trimleft [maskhost [getchanhost $user $chan]] *!]"
set rt [adduser $thand $sitemask]
if {$rt == 1} {set rt "Success"} else {set rt "Failed"}
set rt [chattr $thand ${VAB(default-flags)}]
}
if {([matchchanattr $thand |$VAB(flag) $chan])} {putserv "NOTICE $nick :$user is already no-voiced on $chan"; return 0}
set rt [chattr $thand |+$VAB(flag) $chan]
putserv "NOTICE $nick :Flags for $user\($thand\) are now: $rt"
if {[isvoice $user $chan]} {pushmode $chan -v $user}
}
proc vab_deluser {nick uhost hand chan rest} {
global VAB
subst -nobackslashes -nocommands -novariables rest
if {$rest == ""} {putserv "NOTICE $nick :Calling Syntax: [cmdchar]vab add nick"; return 0}
set user [lindex $rest 0]
if {![validuser $user]} {putserv "NOTICE $nick :$user is not a valid user."; return 0}
if {(![matchchanattr $user |$VAB(flag) $chan])} {putserv "NOTICE $nick :$user isn't on the no-voiced for $chan"; return 0}
set rt [chattr $user |-$VAB(flag) $chan]
putserv "NOTICE $nick :Flags for $user are now: $rt"
if {[isvoice $user $chan]} {pushmode $chan +v $user}
}
bind pub o|o [cmdchar]vablist pub_VABlist
proc pub_VABlist {nick uhost hand channel rest} {
global VAB
if {$VAB(chans) == ""} {puthelp "NOTICE $nick :VAB Channel list is empty."
} else {puthelp "NOTICE $nick :Current VAB channels are: $VAB(chans)"
}
}
# Automated VAB Functions
bind mode - "*-*v*" check:devoices:onmode
proc check:devoices:onmode {nick uhost hand chan mode target} {
global VAB
subst -nobackslashes -nocommands -novariables rest
if {$target == ""} {putserv "NOTICE @$chan :*** \[auto\] VAB: No additions made since there was not a target."; return 0}
# If a user kicks themselves, do not auto-vab them. -siniStar
if {$target == $nick} { return 0}
set user [lindex $target 0]
if {![onchan $user $chan]} {set thand $user} else {set thand [nick2hand $user]}
if {![validuser $thand]} {
if {![onchan $user $chan]} {putserv "NOTICE @$chan :*** \[auto\] VAB: No visible recognition of $user on $chan. Can't lock on target to get a hostmask to add user to VAB by myself."; return 0}
if {$thand == "*"} {set thand $user}
set sitemask "*!*[string trimleft [maskhost [getchanhost $user $chan]] *!]"
set rt [adduser $thand $sitemask]
if {$rt == 1} {set rt "Success"} else {set rt "Failed"}
set rt [chattr $thand ${VAB(default-flags)}]
}
if {([matchchanattr $thand |$VAB(flag) $chan])} {putserv "NOTICE @$chan :*** \[auto\] VAB: $user is already on $chan VAB list. \[No action taken\]"; return 0}
set rt [chattr $thand |+$VAB(flag) $chan]
putserv "NOTICE @$chan :*** \[auto\] VAB: Flags for $user\($thand\) are now: $rt"
}
bind kick - * check:kick
proc check:kick {nick uhost hand chan target reason} {
global VAB
subst -nobackslashes -nocommands -novariables rest
if {$target == ""} {putserv "NOTICE @$chan :*** \[auto\] VAB: No additions made since there was not a target."; return 0}
# If a user kicks themselves, do not auto-vab them. -siniStar
if {$target == $nick} { return 0}
set user [lindex $target 0]
if {![onchan $user $chan]} {set thand $user} else {set thand [nick2hand $user]}
if {![validuser $thand]} {
if {![onchan $user $chan]} {putserv "NOTICE @$chan :*** \[auto\] VAB: No visible recognition of $user on $chan. Can't lock on target to get a hostmask to add user to VAB by myself."; return 0}
if {$thand == "*"} {set thand $user}
set sitemask "*!*[string trimleft [maskhost [getchanhost $user $chan]] *!]"
set rt [adduser $thand $sitemask]
if {$rt == 1} {set rt "Success"} else {set rt "Failed"}
set rt [chattr $thand ${VAB(default-flags)}]
}
if {([matchchanattr $thand |$VAB(flag) $chan])} {putserv "NOTICE @$chan :*** \[auto\] VAB: $user is already on $chan VAB list. \[No action taken\]"; return 0}
set rt [chattr $thand |+$VAB(flag) $chan]
putserv "NOTICE @$chan :*** \[auto\] VAB: Flags for $user\($thand\) are now: $rt"
}
bind sign - * check:quit
proc check:quit {nick uhost hand chan text} {
global VAB
if {[string match "Quit:" $text]} {return 0}
# Don't auto-vab for these QUIT messages either.. -siniStar
if {[string match "*.net *.split" $text]} {return 0}
if {[string match "Connection closed" $text]} {return 0}
if {[string match "Changing host" $text]} {return 0}
if {[string match "Ping timeout:" $text]} {return 0}
if {[string match "TLS" $text]} {return 0}
if {[string match "EOF" $text]} {return 0}
if {[string match "G-Lined" $text]} {
set user [lindex $nick 0]
if {![onchan $user $chan]} {set thand $user} else {set thand [nick2hand $user]}
if {![validuser $thand]} {
if {![onchan $user $chan]} {putserv "NOTICE @$chan :*** \[auto\] VAB: No visible recognition of $user on $chan. Can't lock on target to get a hostmask to add user to VAB by myself."; return 0}
if {$thand == "*"} {set thand $user}
set sitemask "*!*[string trimleft [maskhost [getchanhost $user $chan]] *!]"
set rt [adduser $thand $sitemask]
if {$rt == 1} {set rt "Success"} else {set rt "Failed"}
set rt [chattr $thand ${VAB(default-flags)}]
}
if {([matchchanattr $thand |$VAB(flag) $chan])} {putserv "NOTICE @$chan :*** \[auto\] VAB: $user is already on $chan VAB list. \[No action taken\]"; return 0}
set rt [chattr $thand |+$VAB(flag) $chan]
putserv "NOTICE @$chan :*** \[auto\] VAB: Flags for $user\($thand\) are now: $rt"
}
if {[string match "K-Lined" $text]} {
set user [lindex $nick 0]
if {![onchan $user $chan]} {set thand $user} else {set thand [nick2hand $user]}
if {![validuser $thand]} {
if {![onchan $user $chan]} {putserv "NOTICE @$chan :*** \[auto\] VAB: No visible recognition of $user on $chan. Can't lock on target to get a hostmask to add user to VAB by myself."; return 0}
if {$thand == "*"} {set thand $user}
set sitemask "*!*[string trimleft [maskhost [getchanhost $user $chan]] *!]"
set rt [adduser $thand $sitemask]
if {$rt == 1} {set rt "Success"} else {set rt "Failed"}
set rt [chattr $thand ${VAB(default-flags)}]
}
if {([matchchanattr $thand |$VAB(flag) $chan])} {putserv "NOTICE @$chan :*** \[auto\] VAB: $user is already on $chan VAB list. \[No action taken\]"; return 0}
set rt [chattr $thand |+$VAB(flag) $chan]
putserv "NOTICE @$chan :*** \[auto\] VAB: Flags for $user\($thand\) are now: $rt"
}
if {[string match "D-Lined" $text]} {
set user [lindex $nick 0]
if {![onchan $user $chan]} {set thand $user} else {set thand [nick2hand $user]}
if {![validuser $thand]} {
if {![onchan $user $chan]} {putserv "NOTICE @$chan :*** \[auto\] VAB: No visible recognition of $user on $chan. Can't lock on target to get a hostmask to add user to VAB by myself."; return 0}
if {$thand == "*"} {set thand $user}
set sitemask "*!*[string trimleft [maskhost [getchanhost $user $chan]] *!]"
set rt [adduser $thand $sitemask]
if {$rt == 1} {set rt "Success"} else {set rt "Failed"}
set rt [chattr $thand ${VAB(default-flags)}]
}
if {([matchchanattr $thand |$VAB(flag) $chan])} {putserv "NOTICE @$chan :*** \[auto\] VAB: $user is already on $chan VAB list. \[No action taken\]"; return 0}
set rt [chattr $thand |+$VAB(flag) $chan]
putserv "NOTICE @$chan :*** \[auto\] VAB: Flags for $user\($thand\) are now: $rt"
}
if {[string match "X-Lined" $text]} {
set user [lindex $nick 0]
if {![onchan $user $chan]} {set thand $user} else {set thand [nick2hand $user]}
if {![validuser $thand]} {
if {![onchan $user $chan]} {putserv "NOTICE @$chan :*** \[auto\] VAB: No visible recognition of $user on $chan. Can't lock on target to get a hostmask to add user to VAB by myself."; return 0}
if {$thand == "*"} {set thand $user}
set sitemask "*!*[string trimleft [maskhost [getchanhost $user $chan]] *!]"
set rt [adduser $thand $sitemask]
if {$rt == 1} {set rt "Success"} else {set rt "Failed"}
set rt [chattr $thand ${VAB(default-flags)}]
}
if {([matchchanattr $thand |$VAB(flag) $chan])} {putserv "NOTICE @$chan :*** \[auto\] VAB: $user is already on $chan VAB list. \[No action taken\]"; return 0}
set rt [chattr $thand |+$VAB(flag) $chan]
putserv "NOTICE @$chan :*** \[auto\] VAB: Flags for $user\($thand\) are now: $rt"
}
if {[string match "Killed *" $text]} {
if {[string match "Killed (NickServ*" $text]} {return 0}
set user [lindex $nick 0]
if {![onchan $user $chan]} {set thand $user} else {set thand [nick2hand $user]}
if {![validuser $thand]} {
if {![onchan $user $chan]} {putserv "NOTICE @$chan :*** \[auto\] VAB: No visible recognition of $user on $chan. Can't lock on target to get a hostmask to add user to VAB by myself."; return 0}
if {$thand == "*"} {set thand $user}
set sitemask "*!*[string trimleft [maskhost [getchanhost $user $chan]] *!]"
set rt [adduser $thand $sitemask]
if {$rt == 1} {set rt "Success"} else {set rt "Failed"}
set rt [chattr $thand ${VAB(default-flags)}]
}
if {([matchchanattr $thand |$VAB(flag) $chan])} {putserv "NOTICE @$chan :*** \[auto\] VAB: $user is already on $chan VAB list. \[No action taken\]"; return 0}
set rt [chattr $thand |+$VAB(flag) $chan]
putserv "NOTICE @$chan :*** \[auto\] VAB: Flags for $user\($thand\) are now: $rt"
}
if {[string match "Z-Lined" $text]} {
set user [lindex $nick 0]
if {![onchan $user $chan]} {set thand $user} else {set thand [nick2hand $user]}
if {![validuser $thand]} {
if {![onchan $user $chan]} {putserv "NOTICE @$chan :*** \[auto\] VAB: No visible recognition of $user on $chan. Can't lock on target to get a hostmask to add user to VAB by myself."; return 0}
if {$thand == "*"} {set thand $user}
set sitemask "*!*[string trimleft [maskhost [getchanhost $user $chan]] *!]"
set rt [adduser $thand $sitemask]
if {$rt == 1} {set rt "Success"} else {set rt "Failed"}
set rt [chattr $thand ${VAB(default-flags)}]
}
if {([matchchanattr $thand |$VAB(flag) $chan])} {putserv "NOTICE @$chan :*** \[auto\] VAB: $user is already on $chan VAB list. \[No action taken\]"; return 0}
set rt [chattr $thand |+$VAB(flag) $chan]
putserv "NOTICE @$chan :*** \[auto\] VAB: Flags for $user\($thand\) are now: $rt"
}
}
# End of Automated VAB functions (2.0+)
bind pub o|o [cmdchar]vabadd pub_VABadd
proc pub_VABadd {nick uhost hand channel rest} {
global VAB
if {[voicechan $channel]} {
puthelp "NOTICE $nick :$channel already in VAB List"
return 0
}
puthelp "NOTICE $nick :Adding $channel to VAB List"
lappend VAB(chans) $channel
save_VAB
}
bind pub o|o [cmdchar]vabdel pub_VABdel
proc pub_VABdel {nick uhost hand channel rest} {
global VAB
if {![voicechan $channel]} {
puthelp "NOTICE $nick :$channel not found in VAB List"
return 0
}
puthelp "NOTICE $nick :Removing $channel from VAB List"
set chans $VAB(chans)
set VAB(chans) ""
foreach chan $chans {
if {[string tolower $chan] != [string tolower $channel]} {lappend VAB(chans) $chan}
}
save_VAB
}
proc voicechan {chan} {
global VAB
set chan [string tolower $chan]
set chans [string tolower $VAB(chans)]
if {$chan == "*"} {set chans [string tolower [channels]]}
set dothechan 0
foreach c $chans {
if {($chan == $c)} {set dothechan 1}
}
if {$dothechan == 0} {return 0} else {return 1}
}
proc vab_listuser {nick uhost hand chan rest} {
global VAB
subst -nobackslashes -nocommands -novariables rest
set users [userlist |$VAB(flag) $chan]
putserv "NOTICE $nick :The following are listed as no-voice for $chan: $users"
}
proc load_VAB {} {
global VAB
if {[file exists $VAB(datafile)]} {
set in [open $VAB(datafile) r]
set VAB(chans) [gets $in]
close $in
} {putlog "-VAB- Datafile $VAB(datafile) not found. Using default channel list."}
}
load_VAB
proc save_VAB {} {
global VAB
putlog "Saving VAB Data to $VAB(datafile)"
set out [open $VAB(datafile) w]
puts $out $VAB(chans)
close $out
}
putlog "VoiceAllBut $VAB(ver) Loaded."
return "VoiceAllBut $VAB(ver) Loaded."