| View previous topic :: View next topic |
| Author |
Message |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Sun Apr 02, 2017 6:43 pm Post subject: badwords by MadaliN exception individual words |
|
|
| Code: | #### ++++ Author: MadaliN <madalinmen28@yahoo.com
### ++++ Script name: Badwords
## ++++ Version: 1.0 (2/9/2013)
#
# Commands
# !badwords on/off
# !badwords ban-reason REASON
# !badwords ban-type 1/2/3/4 (!badwords ban-type 1)
# !badwords add WORD/PHRASE
# !badwords del WORD/PHRASE
# !badwords list
setudef flag badwords
bind PUB n !badwords badwords:pub
bind PUBM - * badwords:pubm
proc mh {nuhost type} {
set user [lindex [split $nuhost !] 0]
set host [lindex [split $nuhost !] 1]
switch $type {
1 {return $nuhost}
2 {return *!*@$host}
3 {return *!*$user@$host}
4 {return *!*$user@*}
}
}
proc badwords:pubm {nick uhost hand chan arg} {
global badwords tempbw
if {[channel get $chan badwords]} {
foreach b [array names badwords $chan,*] {
if {[string match -nocase "*[lindex [split $b ,] 1]*" $arg] && ![matchattr $hand n] && ![isop $nick $chan]} {
if {![info exists tempbw($chan,ban-type)]} { set tempbw($chan,ban-type) 2 }
if {![info exists tempbw($chan,reason)]} { set tempbw($chan,reason) "Hit the door ya ;" }
newchanban $chan [mh $nick!$uhost $tempbw($chan,ban-type)] $nick $tempbw($chan,reason) 0
putserv "KICK $chan $nick :$tempbw($chan,reason)"
}
}
}
}
proc badwords:pub {nick uhost hand chan arg} {
global badwords tempbw
set what [join [lrange [split $arg] 1 end]]
switch -exact -- [lindex [split $arg] 0] {
ban-type -
-ban-type {
if {[lindex [split $arg] 1] == ""} { putserv "PRIVMSG $chan :\002$nick\002 - You have to specify ban-type (1/2/3/4)"; return }
if {![regexp {^(1|2|3|4)$} [lindex [split $arg] 1]]} { putserv "PRIVMSG $chan :\002$nick\002 valid types are 1/2/3 or 4 (!badwords ban-type 2)"; return }
set tempbw($chan,ban-type) $what
badwords:save
putserv "PRIVMSG $chan :\002$nick\002 - 'ban-type' has been SET"
}
-r -
-reason {
if {[lindex [split $arg] 1] == ""} { putserv "PRIVMSG $chan :\002$nick\002 - You have to specify ban-reason"; return }
set tempbw($chan,reason) $what
badwords:save
putserv "PRIVMSG $chan :\002$nick\002 - 'ban-reason' has been SET"
}
on -
-on {
channel set $chan +badwords
putserv "PRIVMSG $chan :\002$nick\002 - Succesfully activated \00303badwords\003 script on this channel"
}
off -
-off {
channel set $chan -badwords
putserv "PRIVMSG $chan :\002$nick\002 - Succesfully deactivated \00303badwords\003 script on this channel"
}
add -
-add {
if {[info exists badwords($chan,$what)]} {
putserv "PRIVMSG $chan :\002$nick\002 - '\00312$what\003' already exists in the database."
return
} else {
set badwords($chan,$what) "[unixtime]"
badwords:save
putserv "PRIVMSG $chan :\002$nick\002 - Succesfully added '\00312$what\003' into the database."
return
}
}
del -
-del {
if {![info exists badwords($chan,$what)]} {
putserv "PRIVMSG $chan :\002$nick\002 - '\00312$what\003' was not found in the database."
return
} else {
unset -nocomplain badwords($chan,$what)
badwords:save
putserv "PRIVMSG $chan :\002$nick\002 - Succesfully removed '\00312$what\003' from the database."
return
}
}
list -
-list {
set temp(list) ""
foreach b [array names badwords $chan,*] { lappend temp(list) [lindex [split $b ,] 1] }
if {$temp(list) == ""} { putserv "PRIVMSG $chan :\002$nick\002 - Badwords database for \00303$chan\003 is \002empty\002"; return }
putserv "PRIVMSG $chan :\002$nick\002 - Badwords: [join $temp(list) ", "]"
}
reset -
-reset {
foreach b [array names badwords $chan,*] {
unset -nocomplain badwords($chan,[lindex [split $b ,] 1])
}
badwords:save
putserv "PRIVMSG $chan :\002$nick\002 - Succesfully RESET badwords"
}
}
}
proc badwords:save {} {
global badwords tempbw
set ofile [open badwords w]
puts $ofile "array set badwords [list [array get badwords]]"
puts $ofile "array set tempbw [list [array get tempbw]]"
close $ofile
}
catch {source badwords}
putlog "++++ Succesfully loaded: \00312Badwords TCL Script" |
I need certain words to be excepted by the code.
I have succeeded, but only partially.
Example:
Badwords == puta, sexo, porno, ....more words....
If someone writes the word "diputada", containing the pattern "puta", the bot penalizes.
Partial solution:
| Quote: | proc badwords:pubm {nick uhost hand chan arg} {
global badwords tempbw
if {[channel get $chan badwords]} {
foreach b [array names badwords $chan,*] {
if {[string match -nocase "*diputada*" $arg]} { continue }
if {[string match -nocase "*[lindex [split $b ,] 1]*" $arg] && ![matchattr $hand n] && ![isop $nick $chan]} {
........................................more stuff.................................. |
Why partial?
If someone writes the phrase "la mejor diputada del mundo"
Work perfect! The boT does not penalize the user for writing "diputada".
but.................
If someone writes the phrase "a la diputada le gusta el sexo duro"
The bot does not penalize the word "sexo".
Any solution for the exception of individual words in a sentence, without the bot ceasing to control all other words? _________________ If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks  |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Sun Apr 02, 2017 8:58 pm Post subject: |
|
|
I find this sort of thing to work on some similar scripts.
Replace | Code: | | [string match -nocase "*[lindex [split $b ,] 1]*" $arg] |
with | Code: | | [string match -nocase "* [lindex [split $b ,] 1] *" " $arg "] |
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Sun Apr 02, 2017 11:24 pm Post subject: |
|
|
Work perfectly!
Thanks SpiKe^^ _________________ If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks  |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|