here is script:
Code: Select all
set triggerchar "!"
### Thanks to ppslim for this filter ###
proc swear:filter {str} {
# regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026|\006|\007} $str "" str
regsub -all -nocase {[^a-z,0-9@:/\s\|]} $str "" str
return $str
}
proc swear:filter2 {str} {
# regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026|\006|\007} $str "" str
regsub -all -nocase {[^a-z,0-9*?@:/\s\|]} $str "" str
return $str
}
bind pubm - "* *" badword:pubm:check
#####here starts the script######
####Procedure that puts a new line in the file of triggers for the channel where the trigger was written
bind pub - !addwword badword:pub:add
proc badword:pub:add { nick uhost handle chan arg } {
if { [isop $nick $chan] || [ishalfop $nick $chan] } {
set file "[string trimleft $chan #]_badwords.txt"
set write [open $file a]
set word [lindex $arg 0]
set type [lindex $arg 1]
set reason [lindex $arg 2 end]
if { $type != "1" && $type != "2" && $type != "3" && $type != "4" && $type != "5" && $type != "6" } {
puthelp "NOTICE $nick error: Invaild level type. Try with, 1, 2, 3, 11, 21 or 31."
close $write
return 0
}
if { $word == "" || $type == "" || $reason == "" } {
close $write
return 0
}
puts $write "$word#$reasonź$type"
close $write
putquick "NOTICE $nick :$word added to BadWord list for $chan with level $type."
}
}
bind pub - !addexcept badword:pub:except
proc badword:pub:except { nick uhost handle chan arg } {
if { [isop $nick $chan] || [ishalfop $nick $chan] } {
set dsfile "excepts_[string trimleft $chan #]_badwords.txt"
set dswrite [open $dsfile a]
set dsword [swear:filter2 $arg]
puts $dswrite "$dsword#"
close $dswrite
putquick "NOTICE $nick : Slowo $dsword zostało dodane do listy złych słów kanału $chan."
}
}
####This procedure will be in charge of removing triggers for the chan where the command was written.
bind pub - !remwword badword:pub:rem
proc badword:pub:rem { nick uhost handle chan badword } {
if { $chan != "#emulsfgsfe-help" } {
if { [isop $nick $chan] || [ishalfop $nick $chan ] } {
set file [string trimleft $chan #]_badwords.txt
set tempfile emule-polish_badwords.bak
set readfirst [open $file r]
set linenumb 0
set count 0
putquick "NOTICE $nick :Start: Usuwanie złego słowa."
while { ![eof $readfirst] } {
gets $readfirst line
set helpwanted [string range $line 0 [expr [string first # $line]-1]]
if { $badword != $helpwanted } {
if { $linenumb==0 } {
set writetemp [open $tempfile w]
puts $writetemp $line
close $writetemp
incr linenumb
} else {
set writetemp [open $tempfile a]
puts $writetemp $line
close $writetemp
incr linenumb
}
} else {
incr count
putquick "NOTICE $nick :($count):!addbadword $helpwanted [string range $line [expr [string first # $line]+1] end]"
}
}
close $readfirst
set readfirst2 [open $tempfile r]
set linenumb2 0
while { ![eof $readfirst2] } {
gets $readfirst2 line
if { [string first # $line] != -1 } {
if { $linenumb2==0 } {
set writetemp [open $file w]
puts $writetemp $line
close $writetemp
incr linenumb2
} else {
set writetemp [open $file a]
puts $writetemp $line
close $writetemp
}
}
}
if { $linenumb2==0 } {
set writetemp [open $file w]
close $writetemp
}
close $readfirst2
putquick "NOTICE $nick :End: Usunięto złe słowo."
}
}
}
####Procedure that will get all the triggers from the file and present them to the user who asked for the list of possible commands for the chan.
bind pub - !listwword badword:pub:list
proc badword:pub:list { nick uhost handle chan badword } {
if { $chan != "#emule-fsgsdfhelp" } {
if { [isop $nick $chan] || [ishalfop $nick $chan ] } {
set read [open [string trimleft $chan #]_badwords.txt r]
set text ""
while { ![eof $read] } {
gets $read line
set text "$text [lindex [split $line #] 0]"
}
close $read
set finish [string range $text 1 [expr [string length $text]-2]]
set long [split $finish]
if { [llength $long] > 30 } {
for { set c 0} { $c<[llength $long] } { incr c 30 } {
if { $c==0 } {
putquick "NOTICE $nick : Złe słowa kanału $chan: 4[lrange $long $c [expr $c+29]]"
} else {
putquick "NOTICE $nick : 4[lrange $long $c [expr $c+29]]"
}
}
} else {
putquick "NOTICE $nick : Lista złych słów: 4$finish"
}
}
}
}
####Procedure that shows in the chan the text or the action associated with the trigger written in the channel
proc badword:pubm:check {nick uhost handle chan arg} {
global triggerchar
if { [isop $nick $chan] || [ishalfop $nick $chan] || [isvoice $nick $chan] } {
putlog "used isop/hop/vop"
return 0
}
if {[string match "*@eMule-Polish.MindForge.org" $uhost]} {
putlog "is hosted"
return 0
}
if { ![file exists [string trimleft $chan #]_badwords.txt] } {
return 0
}
set input "[swear:filter $arg]"
set readbw [open [string trimleft $chan #]_badwords.txt r]
while { ![eof $readbw] } {
putlog "i do something"
gets $readbw line
set helpwanted [string range $line 0 [expr [string first # $line]-1]]
set message [string range $line [expr [string first # $line]+1] [expr [string first ź $line]-1]]
set typeof [string range $line [expr [string first ź $line]+1] end]
if { ([string match -nocase "* $helpwanted *" $input] == 1 && $helpwanted != "") || ([string match -nocase "$helpwanted" $input] == 1 && $helpwanted != "") } {
if { $typeof == 4 || $typeof == 5 || $typeof == 6 } {
BadWordKick $nick $uhost $chan $arg $helpwanted $message $typeof $input
putlog "odeslalem"
close $readbw
return 0
} else {
if { [file exists excepts_[string trimleft $chan #]_badwords.txt] } {
set read [open excepts_[string trimleft $chan #]_badwords.txt r]
while { ![eof $read] } {
gets $read line
set searchword [string range $line 0 [expr [string first # $line]-1]]
if { ([string match -nocase "* $searchword *" $input] == 1 && $searchword != "") || ([string match -nocase "$searchword" $input] == 1 && $searchword != "") } {
return 0
} else {
BadWordKick $nick $uhost $chan $arg $helpwanted $message $typeof $input
return 0
}
}
close $read
} else {
BadWordKick $nick $uhost $chan $arg $helpwanted $message $typeof $input
return 0
}
}
}
}
}
proc BadWordKick { nick uhost chan arg helpwanted message typeof input } {
global BadwordWarn
set whost *!*@[lindex [split $uhost "@"] end]
if {$typeof == 1} {
if {![info exists BadwordWarn($uhost)]} {
putquick "PRIVMSG $chan : $nick No Warez : Na kanale obowiazuje zakaz podawania nazw gier, filmow, plikow objetych prawem autorskim."
putquick "NOTICE $nick : $nick: Leż na #chat Jesli chcesz znalesc dany plik wejdz w emule/zakladka szukaj i wpisz jego nazwe. Nastepnie zaznacz ten ktory ma najwieksza dostepnosc zrodel (metoda szukania - serwer globalny badz kad)"
set BadwordWarn($uhost) 1
} elseif {$BadwordWarn($uhost) == 1} {
set BadwordWarn($uhost) 2
putquick "KICK $chan $nick $message ($helpwanted) "
} elseif {$BadwordWarn($uhost) == 2} {
putquick "MODE $chan +b $whost"
putquick "KICK $chan $nick $message ($helpwanted) "
unset BadwordWarn($uhost)
}
} elseif {$typeof == 2} {
if {![info exists BadwordWarn($uhost)]} {
putquick "PRIVMSG $chan : $nick Wypierdalaj na #emule-polish-chat :PPP"
putquick "NOTICE $nick : $nick: rozumiemy sie?!!"
set BadwordWarn($uhost) 1
} elseif {$BadwordWarn($uhost) == 1} {
set BadwordWarn($uhost) 2
putquick "KICK $chan $nick $message ($helpwanted) "
} elseif {$BadwordWarn($uhost) == 2} {
putquick "MODE $chan +b $whost"
putquick "KICK $chan $nick $message ($helpwanted) "
unset BadwordWarn($uhost)
}
} elseif {$typeof == 3} {
if {![info exists BadwordWarn($uhost)] || $BadwordWarn($uhost) == 1} {
putquick "KICK $chan $nick $message ($helpwanted) "
set BadwordWarn($uhost) 2
} elseif {$BadwordWarn($uhost) == 2} {
putquick "MODE $chan +b $whost"
putquick "KICK $chan $nick $message ($helpwanted) "
unset BadwordWarn($uhost)
}
}
} elseif {$typeof == 4} {
if {![info exists BadwordWarn($uhost)]} {
putquick "PRIVMSG $chan : $nick No Warez : Na kanale obowiazuje zakaz podawania nazw gier, filmow, plikow objetych prawem autorskim."
putquick "NOTICE $nick : $nick: Leż na #chat Jesli chcesz znalesc dany plik wejdz w emule/zakladka szukaj i wpisz jego nazwe. Nastepnie zaznacz ten ktory ma najwieksza dostepnosc zrodel (metoda szukania - serwer globalny badz kad)"
set BadwordWarn($uhost) 1
} elseif {$BadwordWarn($uhost) == 1} {
set BadwordWarn($uhost) 2
putquick "KICK $chan $nick $message ($helpwanted) "
} elseif {$BadwordWarn($uhost) == 2} {
putquick "MODE $chan +b $whost"
putquick "KICK $chan $nick $message ($helpwanted) "
unset BadwordWarn($uhost)
}
} elseif {$typeof == 5} {
if {![info exists BadwordWarn($uhost)]} {
putquick "PRIVMSG $chan : $nick Wypierdalaj na #emule-polish-chat :PPP"
putquick "NOTICE $nick : $nick: rozumiemy sie?!!"
set BadwordWarn($uhost) 1
} elseif {$BadwordWarn($uhost) == 1} {
set BadwordWarn($uhost) 2
putquick "KICK $chan $nick $message ($helpwanted) "
} elseif {$BadwordWarn($uhost) == 2} {
putquick "MODE $chan +b $whost"
putquick "KICK $chan $nick $message ($helpwanted) "
unset BadwordWarn($uhost)
}
} elseif {$typeof == 6} {
if {![info exists BadwordWarn($uhost)] || $BadwordWarn($uhost) == 1} {
putquick "KICK $chan $nick $message ($helpwanted) "
set BadwordWarn($uhost) 2
} elseif {$BadwordWarn($uhost) == 2} {
putquick "MODE $chan +b $whost"
putquick "KICK $chan $nick $message ($helpwanted) "
unset BadwordWarn($uhost)
}
}