-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspammyBL.tcl
317 lines (293 loc) · 11.7 KB
/
spammyBL.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
#############################################################################
## _ _ _ _ _ _ _ _ _ _ _ _ _ _ ##
## / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ ##
## ( T | C | L | S | C | R | I | P | T | S | . | N | E | T ) ##
## \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ ##
## ##
## ® BLaCkShaDoW Production ® ##
## ##
## PRESENTS ##
#############################################################################
## spammyBL.tcl 1.0 ##
## Ooooh spaamo mio... ##
## .' ##
## _ :--..----. ##
## \ o') |spamboat| ##
## ;-._: |-.__.---' ##
## \ | _,: ##
## ':-:._______\/|____,-'.' ##
## '-.__.____.\__.__,-' ##
## nO mOrE SPAM \. nO mOrE SPAM nO mOrE SPAM amSP ##
## nO mOrE SPAM nO mOrE SPAM ' nO mOrE SPAM nO mOrE SPAM nO mOrE SPAM ##
## ##
## - #TCL-HELP @ UNDERNET - ##
## ##
#############################################################################
## ##
## INSTALLATION: ##
## ++ Edit spammyBL.tcl script & place it into your /scripts directory.##
## ++ add "source scripts/spammyBL.tcl" to your eggdrop.conf & rehash. ##
## ##
#############################################################################
## ##
## COMMANDS: ##
## ##
## To activate: ##
## .chanset +nospammy | from BlackTools: .set #channel +nospammy ##
## ##
## !rem <IP> - removes an IP from SpammyBlackList. ##
## (without *!*@, just digits | eq: !rem 12.12.12.12) ##
## ##
## !set [+|-]nospammy.xonly - activate/deactivate X ban support. ##
## ##
#############################################################################
## ##
## PERSONAL AND NON-COMMERCIAL USE LIMITATION. ##
## ##
## This program is provided on an "as is" and "as available" basis, ##
## with ABSOLUTELY NO WARRANTY. Use it at your own risk. ##
## ##
## Use this code for personal and NON-COMMERCIAL purposes ONLY. ##
## ##
## Unless otherwise specified, YOU SHALL NOT copy, reproduce, sublicense, ##
## distribute, disclose, create derivatives, in any way ANY PART OF ##
## THIS CONTENT, nor sell or offer it for sale. ##
## ##
## You will NOT take and/or use any screenshots of this source code for ##
## any purpose without the express written consent or knowledge of author.##
## ##
## You may NOT alter or remove any trademark, copyright or other notice ##
## from this source code. ##
## ##
## Copyright 2008 - 2018 @ WwW.TCLScripts.NET ##
## ##
## ** based on ideas picked & sugested by [email protected] ##
## ##
#############################################################################
#############################################################################
## CONFIGURATIONS ##
#############################################################################
# SpammyList default reason
set spammy(breason) "Spam is off-topic on this network"
# SpammyList X Ban Time
set spammy(xban_time) "24h"
# SpammyList X Ban Level
set spammy(xban_level) "75"
###
# Flags needed for !rem command
# - like (mn|o or mn for global only)
###
set spammy(flags) "mno|MAO"
##############################################################################
### DO NOT MODIFY HERE UNLESS YOU KNOW WHAT YOU'RE DOING ###
##############################################################################
###
# Bindings
# - using commands
bind join - * spammy:ident:check
bind pubm - * spammy:message:check
bind join - * spammy:blacklist
bind pub $spammy(flags) !rem spammy:black:remove
###
# Channel flags
setudef flag nospammy
setudef flag nospammy.xonly
###
# SpammyList database file
set spammy(black_file) "freenode_black.txt"
if {![file exists $spammy(black_file)]} {
set file [open $spammy(black_file) w]
close $file
}
###
# SpammyList counter file
set spammy(count_file) "freenode_counter.txt"
if {![file exists $spammy(count_file)]} {
set file [open $spammy(count_file) w]
close $file
}
###
proc spammy:ident:check {nick host hand chan} {
global spammy
if {![channel get $chan nospammy]} {
return
}
if {![regexp {^[~]} [lindex [split $host "@"] 0]]} {
return
}
set ident [string map {"~" ""} [string tolower [lindex [split $host "@"] 0]]]
if {[string match -nocase "$ident*" $nick]} {
set spammy(check:$nick) 1
utimer 20 [list spammy:unset $nick]
}
}
###
proc spammy:unset {var} {
global spammy
if {[info exists spammy(check:$var)]} {
unset spammy(check:$var)
}
}
###
proc spammy:message:check {nick host hand chan arg} {
global spammy
if {![channel get $chan nospammy]} {
return
}
set host [lindex [split $host "@"] 1]
set message [lrange [split $arg] 0 end]
if {[info exists spammy(check:$nick)]} {
if {[regexp {(ј|о|Ꭲ|ᥱ|ᥒ|і|!|ዘ|Ꭱ|Ϻ|Ϲ|ᖇ|Ꮤ|Ꭰ)} $message]} {
spammy:black:add $host
spammy:banall:chans $nick $host
}
}
}
###
proc spammy:black:add {host} {
global spammy
set check_valid [spammy:black:check $host]
if {$check_valid > -1} {
return 0
}
set file [open $spammy(black_file) a]
puts $file $host
close $file
}
###
proc spammy:black:check {host} {
global spammy
set file [open $spammy(black_file) r]
set size [file size $spammy(black_file)]
set data [split [read $file $size] \n]
close $file
set get [lsearch $data $host]
return $get
}
###
proc spammy:black:rem {host} {
global spammy
set file [open $spammy(black_file) "r"]
set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
set temp "spammy_temp.$timestamp"
set tempwrite [open $temp w]
while {[gets $file line] != -1} {
set read_ip [lindex [split $line] 0]
if {[string equal -nocase $read_ip $host]} {
continue
} else {
puts $tempwrite $line
}
}
close $tempwrite
close $file
file rename -force $temp $spammy(black_file)
}
###
proc spammy:blacklist {nick host hand chan} {
global spammy
#if {![botisop $chan]} { return }
set host [lindex [split $host "@"] 1]
set check_valid [spammy:black:check $host]
if {$check_valid < 0} {
return 0
}
set counter [spammy:incr:count]
if {[channel get $chan nospammy.xonly] && [onchan "X" $chan]} {
#New Functionality -- be more Sigyn-ish.
# Stop spambots more effectively (and quickly) by sending a KILL,
# followed by an immediate GLINE. (Then duplicate it to either
# Uworld2 or EUworld)
# -- siniStar
putquick "KILL $nick :Spam is off-topic on this network - $counter"
putquick "GLINE +*@$host * 3600 :Banned for spamming - Contact [email protected] for more information. ($chan - $counter)"
putquick "PRIVMSG Uworld2 :GLINE ADD *@$host !T 14d Banned for spamming - Contact [email protected] with GID# for more information. ($chan - $counter)"
putserv "PRIVMSG #Opers :*** \002Warning\002 Spam-Characters activated by $nick in $chan"
# putquick "PRIVMSG X :ban $chan *!*@$host $spammy(xban_time) $spammy(breason) - $counter -"
# putquick "PRIVMSG EUworld :GLINE ADD *@$host !T 7d Spam is off-topic on this network - $counter"
} else {
# putquick "MODE $chan +b $host"
# putquick "KICK $chan $nick :$spammy(breason) - $counter -"
putquick "KILL $nick :Spam is off-topic on this network - $counter"
putquick "GLINE +*@$host * 3600 :Banned for spamming - Contact [email protected] for more information. ($chan - $counter)"
putquick "PRIVMSG Uworld2 :GLINE ADD *@$host !T 14d Banned for spamming - Contact [email protected] with GID# for more information. ($chan - $counter)"
putserv "PRIVMSG #Opers :*** \002Warning\002 Spam-Characters activated by $nick in $chan"
# putquick "PRIVMSG EUworld :GLINE ADD *@$host !T 7d Spam is off-topic on this network - $counter"
putlog "$spammy(projectName) - Kicked $nick from '$chan' - '$spammy(breason)'."
}
}
# Credits
set spammy(projectName) "spammyBL"
set spammy(author) "BLaCkShaDoW & skew"
set spammy(website) "wWw.TCLScriptS.NeT"
set spammy(email) "info\[at\]tclscripts.net"
set spammy(version) "v1.0"
###
proc spammy:banall:chans {nick host} {
global spammy
set channels ""
foreach chan [channels] {
if {[botisop $chan]} {
if {[channel get $chan nospammy]} {
if {[onchan $nick $chan]} {
lappend channels $chan
}
}
}
}
if {$channels != ""} {
spammy:ban:chan $channels $nick $host 0
}
}
###
proc spammy:ban:chan {channels nick host num} {
global spammy
set incr 0
set counter [spammy:incr:count]
set chan [lindex $channels $num]
if {[channel get $chan nospammy.xonly] && [onchan "X" $chan]} {
putquick "PRIVMSG X :ban $chan *!*@$host $spammy(xban_time) $spammy(breason) - $counter -"
} else {
putquick "MODE $chan +b $host"
putquick "KICK $chan $nick :$spammy(breason) - $counter -"
putlog "$spammy(projectName) - Kicked $nick from '$chan' - '$spammy(breason)'."
}
set incr [expr $num + 1]
if {[lindex $channels $incr] != ""} {
spammy:ban:chan $channels $nick $host $incr
}
}
###
proc spammy:black:remove {nick host hand chan arg} {
global spammy
set ip [lindex [split $arg] 0]
if {$ip == ""} {
putserv "NOTICE $nick :USAGE SYNTAX:\002 !rem\002 \[host|ip\]"
return
}
set check_it [spammy:black:check $ip]
if {$check_it < 0} {
putserv "NOTICE $nick :Didn't found \002$ip\002 in spammyBL."
return
}
spammy:black:rem $ip
putserv "NOTICE $nick :Removed \002$ip\002 from spammyBL."
}
###
proc spammy:incr:count {} {
global spammy
set file [open $spammy(count_file) r]
set data [read -nonewline $file]
close $file
if {$data == ""} { set data 0 }
set incr [expr $data + 1]
set file [open $spammy(count_file) w]
puts $file $incr
close $file
return $incr
}
putlog "\002$spammy(projectName) $spammy(version)\002 by\002 $spammy(author)\002 ($spammy(website)): Loaded & initialised.."
#########
##############################################################################
### *** THE END *** ###
##############################################################################