|
Joined: Mar 2005
Posts: 17
Pikka bird
|
OP
Pikka bird
Joined: Mar 2005
Posts: 17 |
hi all what is wrong with this code guys It has 3 options to check 1) warn before kick and ban 2) kick 3) kick/ban ..so when i check 2 options (warn + kick or ban) its work perfect but when i check only the kick option or kick.ban option (without a warning) it kicks the users what ever they say either a badword either not !! any idea where is bug ??? this on text :
;;on text script section;;;;
on on @*:action:*:$($readini($+(",$scriptdirsettings.ini,"), Badwords, Channels)):check.for.ban $1-
on @*:text:*:$($readini($+(",$scriptdirsettings.ini,"), Badwords, Channels)):check.for.ban $1-
alias -l check.for.ban {
var %x 1
while ( %x <= $numtok($1-,32) ) {
if ( $hfind(badwords,$gettok($1-,%x,32),1,W) != $null ) {
;;warn;;
if ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Warn) == 1 ) {
if ( $hget(badwordswarn,$+($nick,.,$chan)) == $null ) {
hinc -m badwordswarn $+($nick,.,$chan)
/msg $chan $nick $readini($+(",$scriptdirsettings.ini,"), Badwords, Warnmsg ) Badword: $hfind(badwords,$gettok($1-,%x,32),1,W)
}
else {
hinc -m badwordswarn $+($nick,.,$chan)
}
;;warned kick;;
if ( $hget(badwordswarn,$+($nick,.,$chan)) > 1 ) && ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Kick) == 1 ) && ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Ban) == 0 ) {
.kick $chan $nick $readini($+(",$scriptdirsettings.ini,"), Badwords, Reason Badword: $hfind(badwords,$gettok($1-,%x,32),1,W) )
hdel badwordswarn $+($nick,.,$chan)
}
;;warned kickban;;
elseif ( $hget(badwordswarn,$+($nick,.,$chan)) > 1 ) && ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Kick) == 0 ) && ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Ban) == 1 ) {
.ban $+(-u,$readini($+(",$scriptdirsettings.ini,"), Badwords, Bantime)) $chan $nick $readini($+(",$scriptdirsettings.ini,"), Badwords, Reason ) $calc( $readini($+(",$scriptdirsettings.ini,"),Badwords,Bantime) / 60 ) Minutes
/msg $chan $nick $readini($+(",$scriptdirsettings.ini,"), Badwords, Reason ) Banned $calc( $readini($+(",$scriptdirsettings.ini,"),Badwords,Bantime) / 60 ) Minutes. Badword: $hfind(badwords,$gettok($1-,%x,32),1,W)
hdel badwordswarn $+($nick,.,$chan)
}
}
}
;;no warn;;
if ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Warn) == 0 ) {
;;;no warn kick;;;
if ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Kick) == 1 ) && ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Ban) == 0 ) {
.kick $chan $nick $readini($+(",$scriptdirsettings.ini,"), Badwords, Reason Badword: $hfind(badwords,$gettok($1-,%x,32),1,W) )
}
;;;no warn kickban
elseif ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Kick) == 0 ) && ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Ban) == 1 ) {
.ban $+(-ku,$readini($+(",$scriptdirsettings.ini,"), Badwords, Bantime)) $chan $nick $readini($+(",$scriptdirsettings.ini,"), Badwords, Reason ) Banned: $calc( $readini($+(",$scriptdirsettings.ini,"),Badwords,Bantime) / 60 ) Minutes Badword: $hfind(badwords,$gettok($1-,%x,32),1,W)
}
}
inc %x
}
}
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
Check this out I have now replied to the bug u detected in itOn your code here, you were exiting out one to many } so you had exited the if ( $hfind(badwords,$gettok($1-,%x,32),1,W) != $null ) { thus any word well trigger the NO WARN section. This i have corrected by moving the } before the ";;no warn;;" line to before the "inc %x" line. I also added some RETURN's becuase I dont think once you have warned/kicked/baned someone you want to keep checking the line any more, currently if it was set to kick them, and they said 3 badwords in one sentence it would try and kick em 3 times.
alias -l check.for.ban {
var %x 1
while ( %x <= $numtok($1-,32) ) {
if ( $hfind(badwords,$gettok($1-,%x,32),1,W) != $null ) {
;;warn;;
if ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Warn) == 1 ) {
if ( $hget(badwordswarn,$+($nick,.,$chan)) == $null ) {
hinc -m badwordswarn $+($nick,.,$chan)
/msg $chan $nick $readini($+(",$scriptdirsettings.ini,"), Badwords, Warnmsg ) Badword: $hfind(badwords,$gettok($1-,%x,32),1,W)
RETURN
}
else {
hinc -m badwordswarn $+($nick,.,$chan)
}
;;warned kick;;
if ( $hget(badwordswarn,$+($nick,.,$chan)) > 1 ) && ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Kick) == 1 ) && ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Ban) == 0 ) {
.kick $chan $nick $readini($+(",$scriptdirsettings.ini,"), Badwords, Reason Badword: $hfind(badwords,$gettok($1-,%x,32),1,W) )
hdel badwordswarn $+($nick,.,$chan)
RETURN
}
;;warned kickban;;
elseif ( $hget(badwordswarn,$+($nick,.,$chan)) > 1 ) && ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Kick) == 0 ) && ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Ban) == 1 ) {
.ban $+(-u,$readini($+(",$scriptdirsettings.ini,"), Badwords, Bantime)) $chan $nick $readini($+(",$scriptdirsettings.ini,"), Badwords, Reason ) $calc( $readini($+(",$scriptdirsettings.ini,"),Badwords,Bantime) / 60 ) Minutes
/msg $chan $nick $readini($+(",$scriptdirsettings.ini,"), Badwords, Reason ) Banned $calc( $readini($+(",$scriptdirsettings.ini,"),Badwords,Bantime) / 60 ) Minutes. Badword: $hfind(badwords,$gettok($1-,%x,32),1,W)
hdel badwordswarn $+($nick,.,$chan)
RETURN
}
}
;;no warn;;
if ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Warn) == 0 ) {
;;;no warn kick;;;
if ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Kick) == 1 ) && ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Ban) == 0 ) {
.kick $chan $nick $readini($+(",$scriptdirsettings.ini,"), Badwords, Reason Badword: $hfind(badwords,$gettok($1-,%x,32),1,W) )
RETURN
}
;;;no warn kickban
elseif ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Kick) == 0 ) && ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Ban) == 1 ) {
.ban $+(-ku,$readini($+(",$scriptdirsettings.ini,"), Badwords, Bantime)) $chan $nick $readini($+(",$scriptdirsettings.ini,"), Badwords, Reason ) Banned: $calc( $readini($+(",$scriptdirsettings.ini,"),Badwords,Bantime) / 60 ) Minutes Badword: $hfind(badwords,$gettok($1-,%x,32),1,W)
RETURN
}
}
}
inc %x
}
}
If u dont swap to the other threads alias now i fixed it, then you might like to look at this code below, its the same as above but with the repeditive code removed.
alias -l check.for.ban {
var %x 1
while ( %x <= $numtok($1-,32) ) {
if ( $hfind(badwords,$gettok($1-,%x,32),1,W) != $null ) {
;;warn;;
if ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Warn) == 1 ) {
hinc -m badwordswarn $+($nick,.,$chan)
if ( $hget(badwordswarn,$+($nick,.,$chan)) == 1 ) {
msg $chan $nick $readini($+(",$scriptdirsettings.ini,"), Badwords, Warnmsg ) Badword: $hfind(badwords,$gettok($1-,%x,32),1,W)
RETURN
}
}
;;;no warning needed OR warning now over 1 so check for kick/bans'
if ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Warn) == 0 ) || ( $hget(badwordswarn,$+($nick,.,$chan)) > 1 ) {
;;;kick
if ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Kick) == 1 ) && ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Ban) == 0 ) {
.kick $chan $nick $readini($+(",$scriptdirsettings.ini,"), Badwords, Reason Badword: $hfind(badwords,$gettok($1-,%x,32),1,W) )
hadd -m badwordswarn . | hdel badwordswarn $+($nick,.,$chan)
RETURN
}
;;;kickban
elseif ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Kick) == 0 ) && ( $readini($+(",$scriptdirsettings.ini,"), Badwords, Ban) == 1 ) {
.ban $+(-ku,$readini($+(",$scriptdirsettings.ini,"), Badwords, Bantime)) $chan $nick $readini($+(",$scriptdirsettings.ini,"), Badwords, Reason ) Banned: $calc( $readini($+(",$scriptdirsettings.ini,"),Badwords,Bantime) / 60 ) Minutes Badword: $hfind(badwords,$gettok($1-,%x,32),1,W)
hadd -m badwordswarn . | hdel badwordswarn $+($nick,.,$chan)
RETURN
}
}
}
inc %x
}
}
* i use "hadd -m badwordswarn . | hdel badwordswarn $+($nick,.,$chan)" and not just "hdel badwordswarn $+($nick,.,$chan)" becuase if there is no badwordswarn hashtable a hdel well error, so i ensure table exists using a hadd (i could have checekd it with an if but im lazy!)
|
|
|
|
Joined: Mar 2005
Posts: 17
Pikka bird
|
OP
Pikka bird
Joined: Mar 2005
Posts: 17 |
It's ok now DaveC thank u so mutch u help me to mutch all this time thanks again (thanks for the bug also)
|
|
|
|
|