expl: !badwords or $badwords the bot say notice
bot notice lists global badwords etc etc ( all cmd)
And instead of kick or kickban -------> 1 bad word to inform (warning!!!) repeat bad word kick et 3 repeat banned 2 mns
thx for help
Code: Select all
#badwords.tcl
#by Elven <elven@elven.de>
# LEGAL DISCLAIMER:
# THIS SCRIPT IS UNDER THE GPL LICENCE.
# For more information see the accompanying gpl.txt
####################
# Quick Start:
# .badwords - lists global badwords
# .badwords #channel - lists channel badwords
# .badwords all - lists all badwords
# .+badword <regexp> - adds global badword
# .+badword #channel <rx> - adds channel badword
# .-badword <id> - removes global badword (see .badwords for id)
# .-badword #channel <id> - go figure
#
# .chanset #channel +badwords - enable badword protection for this channel
####################
# configuration
set badword(cflag) "m|m"
#what flags are needed to edit badwords? (global|channel)
set badword(flag) "of|of"
#users not affected by badword scan
set badword(reaction) 1
# 0 - kick
# 1 - kickban
set badword(banmsg) {
"Badword."
}
#reason/comment on ban
set badword(bantime) 10
#ban time in minutes
set badword(savefile) "$datapath/badwords"
#file format:
# =channelname/-globals
# ~badword
# ~badword
# =anotherchannel
# ~badword
# ...
set badword(quietsave) 1
#dont log 'Saved on automatic save.'
####################
# code below
setudef flag badwords
bind dcc "-" "+badword" badword:add
bind dcc "-" "-badword" badword:del
bind dcc "-" "badwords" badword:list
bind dcc "-" "badword" badword:list
bind evnt "-" "save" badword:save
bind evnt "-" "loaded" badword:load
bind pubm "-" "*" badword:msg
proc badword:add {h i t} {
global badword badwords
set lst [split $t]
set chn [join [lindex $lst 0]]
set chn [string tolower $chn]
if {[llength $lst] == 0} {
putidx $i "\002Syntax:\002 +badword \[#channel\] <regexp string>"
putidx $i " Adds a channel or (if channel is ommited) global badword."
return 0
}
if {[regexp {^#.+$} $chn]} {
if {![matchattr $h $badword(cflag) $chn]} {
putidx $i "Only channel masters and above can add channel badwords."
return 1
}
set bword [join [lrange $lst 1 end]]
if {[string trim $bword] == ""} { putidx $i "Please specify a badword to add." ; return 0 }
if {![info exists badwords($chn)]} {
set badwords($chn) [list $bword]
} {
lappend badwords($chn) $bword
}
putidx $i "Added $bword as $chn channel badword."
} {
if {![matchattr $h $badword(cflag)]} {
putidx $i "Only global masters and above can add global badwords."
return 1
}
set bword [join $lst]
if {[string trim $lst] == ""} { putidx $i "Please specify a badword to add." ; return 0 }
set chn "-global"
lappend badwords($chn) $bword
putidx $i "Added $bword as global badword."
}
return 1
}
proc badword:del {h i t} {
global badword badwords
set lst [split $t]
set chn [join [lindex $lst 0]]
set chn [string tolower $chn]
if {[llength $lst] == 0} {
putidx $i "\002Syntax:\002 -badword \[#channel\] <number>"
putidx $i " Removes a channel or (if channel is ommited) global badword. Number specifies the item in .badwords"
return 0
}
if {[regexp {^#.+$} $chn]} {
if {![matchattr $h $badword(cflag) $chn]} {
putidx $i "Only channel masters and above can delete channel badwords."
return 1
}
set id [join [lindex $lst 1]]
} {
if {![matchattr $h $badword(cflag)]} {
putidx $i "Only global masters and above can delete global badwords."
return 1
}
set id [join [lindex $lst 0]]
set chn "-global"
}
set bwo [lindex $badwords($chn) $id]
if {$bwo == ""} {
putidx $i "Invalid ID."
return 1
}
set badwords($chn) [lreplace $badwords($chn) $id $id]
if {$chn=="-global"} {
putidx $i "Removed global badword $bwo."
} {
putidx $i "Removed channel badword $bwo on $chn."
}
return 1
}
proc badword:list {h i t} {
global badword badwords
set lst [split $t]
set chn [join [lindex $lst 0]]
set chn [string tolower $chn]
if {$chn == ""} {
if {![matchattr $h $badword(cflag)]} {
putidx $i "Only global masters and above can list global badwords."
return 1
}
if {[info exists badwords(-global)]} {
if {[llength $badwords(-global)]==0} {
putidx $i "No global badwords."
} {
putidx $i "Global badwords:"
set l 0
foreach x $badwords(-global) {
putidx $i "$l: $x"
incr l
}
putidx $i "End of list."
}
} {
putidx $i "No global badwords."
}
return 1
} elseif {$chn == "all"} {
if {![matchattr $h $badword(cflag)]} {
putidx $i "Only global masters and above can list all badwords."
return 1
}
foreach x [array names badwords] {
if {[llength $badwords($x)]==0} { continue }
if {$x == "-global"} {
putidx $i "\002Global\002 Badwords"
} {
putidx $i "Badwords for channel \002$x\002"
}
set l 0
foreach y $badwords($x) {
putidx $i " $l: $y"
incr l
}
}
putidx $i "End of list."
return 1
} elseif {$chn == "save"} {
if {![matchattr $h $badword(cflag)]} {
putidx $i "Only global masters and above can save badwords."
return 1
}
badword:save "noautosave"
} elseif {$chn == "load"} {
if {![matchattr $h $badword(cflag)]} {
putidx $i "Only global masters and above can load badwords."
return 1
}
badword:load "noautoloaded"
} elseif {[regexp {^#.+$} $chn]} {
if {![matchattr $h $badword(cflag) $chn]} {
putidx $i "Only channel masters and above can list channel badwords."
return 1
}
if {[info exists badwords($chn)]} {
if {[llength $badwords($chn)]==0} {
putidx $i "No badwords for channel $chn."
} {
putidx $i "$chn badwords:"
set l 0
foreach x $badwords($chn) {
putidx $i "$l: $x"
incr l
}
putidx $i "End of list."
}
} {
putidx $i "No badwords for channel $chn."
}
#ist channel badwords
return 1
} else {
putidx $i "\002Syntax:\002 : badwords \[save|load|all|#channel\]"
return 0
}
}
proc badword:save {t} {
global badword badwords
set f [open $badword(savefile) w]
foreach x [array names badwords] {
if {[llength $badwords($x)]==0} { continue }
puts $f "=$x"
foreach y $badwords($x) {
puts $f "~$y"
}
}
close $f
if {$t != "save"} {
if {!$badword(quietsave)} { putlog "Saved badwords." }
}
}
proc badword:load {t} {
global badword badwords
catch { unset badwords }
set f [open $badword(savefile) r]
set curr "--"
while {![eof $f]} {
set ln [gets $f]
if {![regexp "^(\[=~\])(.+)$" $ln uun t r]} { continue }
if {$t == "="} {
set curr $r
} {
if {![info exists badwords($curr)]} {
set badwords($curr) [list $r]
} {
lappend badwords($curr) $r
}
}
}
close $f
putlog "Loaded badwords."
}
proc badword:msg {n u h c t} {
global badwords badword
set c [string tolower $c]
set hit 0
if {![channel get $c badwords]} { return 0 }
if {[isop $n $c]} { if {[channel get $c dontkickops]} { return 0 } }
if {[matchattr $h $badword(flag) $c]} { return 0 }
if {[info exists badwords(-global)]} {
foreach x $badwords(-global) {
if {[string trim $x] == ""} { continue }
if {[regexp -nocase $x $t]} { set hit 1 ; break }
}
}
if {!$hit && [info exists badwords($c)]} {
foreach x $badwords($c) {
if {[string trim $x] == ""} { continue }
if {[regexp -nocase $x $t]} { set hit 1 ; break }
}
}
if {$hit} {
if {$badword(reaction) == 1} {
newchanban $c [maskhost $u] "badwords" [join [lindex $badword(banmsg) [rand [llength $badword(banmsg)]]]] $badword(bantime)
} {
putserv "KICK $c $n :$badword(banmsg)"
}
}
}
putlog "Badwords by Elven loaded."