| View previous topic :: View next topic |
| Author |
Message |
Torrevado Op
Joined: 02 Aug 2006 Posts: 101
|
Posted: Mon Dec 08, 2008 1:24 pm Post subject: annoy check |
|
|
Hi, I'm trying to modify channel protection script by gozzip. What I want is to add some chars like "annoying". I did it this way, but it doesn't work:
| Code: | | if {($letter == "?") || ($letter == "!") || ($letter == "$") || ($letter == "_") || ($letter == "*") || ($letter == "%") || ($letter == "¿") || ($letter == "¡") || ($letter == "ñ") || ($letter == "á") || ($letter == "é") || ($letter == "í") || ($letter == "ó") || ($letter == "ú") || ($letter == "[") || ($letter == "]") || ($letter == "{") || ($letter == "}") || ($letter == "<") || ($letter == ">") || ($letter == "|") || ($letter == "ç") || ($letter == ".") || ($letter == "¨")} {incr annoy; incr total_annoy} |
Entire proccess (original one) is:
| Code: |
set annoy_count(z:z) 0
set annoy_triggered(z:z) 0
##CHECK_ANNOY
proc check_annoy {nick uhost hand chan text} {
#load some global variables
global chanpro annoy_count annoy_triggered botnick annoy_ban_type
#set the annoy variables
set annoy 0
set total_annoy 0
set triggered 0
#check if annoy-check is disabled, if so - return
if {!$chanpro(annoy)} {return 0}
#check if other bot is actually typing the word <- Added to fix bugs
if {[matchattr $hand +b]} {return 0}
#check each char with a loop
foreach word [split $text] {
foreach letter [split $word ""] {
if {($letter == "?") || ($letter == "!") || ($letter == "$") || ($letter == "_") || ($letter == "*") || ($letter == "%")} {incr annoy; incr total_annoy}
}
#checks if the length of the annoy is huge enough
if {$annoy >= $chanpro(annoy_length)} {break} {set annoy 0}
}
#set some vars again
set total_string [expr [string length $text] - [regsub -all -- " " $text * *]]
set percent [expr $total_annoy.0 / $total_string * 100]
#check if the annoy was big enough
if {$annoy >= $chanpro(annoy_length)} {
set triggered 1
}
#check if the percentage was big enough, and string was long enough to count
if {$total_string >= $chanpro(annoy_minimum) && $percent >= $chanpro(annoy_percent)} {
set triggered 1
}
#check if we got a trigger
if {!$triggered} {
return 0
}
##now, proceed to the actual actions the bot will take
##create a timer for the violation, kick/ban..
#checks if the user is an op, if so check if protect_ops is enabled
if {([matchattr $hand o|o $chan] || [isop $nick $chan]) && $chanpro(protect_ops)} {
putserv "[subst $chanpro(op_method)] :[subst $chanpro(op_annoy)]"
return 0
}
#check if the dude has triggered before
if {![info exists annoy_count($uhost:$chan)]} {
set annoy_count($uhost:$chan) 0
}
#increase the variable thar tracks number of offences
incr annoy_count($uhost:$chan)
#check if we allready have a timer set, and kill it if so (prevent error msgs and bad timers)
if {[info exists annoy_triggered($uhost:$chan)]} {killtimer $annoy_triggered($uhost:$chan); list unset annoy_triggered($uhost:$chan)}
#set our timer, bound to a variable..
set annoy_triggered($uhost:$chan) [timer $chanpro(remember) [list unset annoy_count($uhost:$chan)]]
timer $chanpro(remember) [list unset annoy_triggered($uhost:$chan)]
#check what offencenr this was, and act from it
if {$annoy_count($uhost:$chan) == 1} {putserv "[subst $chanpro(warning_method)] :[subst $chanpro(warn_annoy)]"}
if {$annoy_count($uhost:$chan) == 2} {putserv "KICK $chan $nick :[subst $chanpro(kick_annoy)]"}
if {$annoy_count($uhost:$chan) == 3} {
set bmask [annoy:masktype $nick!$uhost $annoy_ban_type]
newchanban $chan $bmask $botnick [subst $chanpro(ban_annoy)] $chanpro(ban_time_annoy)
putserv "KICK $chan $nick :[subst $chanpro(ban_annoy)]"
set annoy_count($uhost:$chan) 2
putloglev o * "*** Kickban $nick from $chan for doing $chanpro(ban_annoy)"
}
} ;#end proc
|
Thanks  |
|
| Back to top |
|
 |
tomekk Master

Joined: 28 Nov 2008 Posts: 255 Location: Oswiecim / Poland
|
Posted: Mon Dec 08, 2008 2:56 pm Post subject: |
|
|
what a long IF
try to escape these two chars:
| Code: | | ($letter == "[") || ($letter == "]") |
this should be like this:
| Code: | | ($letter == "\[") || ($letter == "\]") |
:> |
|
| Back to top |
|
 |
Torrevado Op
Joined: 02 Aug 2006 Posts: 101
|
Posted: Mon Dec 08, 2008 5:14 pm Post subject: |
|
|
Thanks, it fixed "[", "]", "{" and "}" chars, but nothing to do with others (¿ ¡ á é í ó ú ñ ...etc)  |
|
| Back to top |
|
 |
tomekk Master

Joined: 28 Nov 2008 Posts: 255 Location: Oswiecim / Poland
|
Posted: Mon Dec 08, 2008 7:22 pm Post subject: |
|
|
hmm, its working for me:
| Code: | [tomekk@zonk]:/home/temp# ./test.tcl ç
passed |
Maybe your channel code page is diffrent from bot code page, don't know.
I don't think so that can be because code page is wrong.
Write some simple script with one "if" and one special char like "ç" and test it.
like:
| Code: | bind pub - !test test_proc
proc test_proc {n u h c a} {
set char "ç"
if {$char == $a} {
putquick "PRIVMSG $c :working...."
}
} |
and run "!test ç" (or some other special char, exept [ ] {} ! ? etc, use some language special char)
:> |
|
| Back to top |
|
 |
Torrevado Op
Joined: 02 Aug 2006 Posts: 101
|
Posted: Tue Dec 09, 2008 12:19 pm Post subject: |
|
|
This test script works with all standard chars, even [ ] { }, but not with my language special chars like ç, ñ, ¿, á ...etc
I guess what happens is what you said, but I don't know what does it exactly mean, and if it can be fixed
| tomekk wrote: | Maybe your channel code page is diffrent from bot code page, don't know.
I don't think so that can be because code page is wrong. |
I'm lost in Space  |
|
| Back to top |
|
 |
tomekk Master

Joined: 28 Nov 2008 Posts: 255 Location: Oswiecim / Poland
|
Posted: Tue Dec 09, 2008 12:38 pm Post subject: |
|
|
| Torrevado wrote: | This test script works with all standard chars, even [ ] { }, but not with my language special chars like ç, ñ, ¿, á ...etc
I guess what happens is what you said, but I don't know what does it exactly mean, and if it can be fixed
| tomekk wrote: | Maybe your channel code page is diffrent from bot code page, don't know.
I don't think so that can be because code page is wrong. |
I'm lost in Space  |
Sometimes problems with code page are rly crazy, I had once a problem with code page in one polish script with special polish UTF chars, but anyway
U want to allow only ASCII chars, like abcde ABCD etc etc, [] ! {} all without special language char?
U can always check letter ASCII code, if it is bigger than 127 then you know that is some other char, f.e. special language char.
http://www.asciitable.com/
little code which can be helpful:
| Code: |
set char "á"
scan $char "%c" int
puts $int |
This will return "225" (cause á code is 225) and this is biggerr than 127 then this is not "normal" char.
Or try to do this i normal way, find char unicode code or some other code page and test it.
Try it. |
|
| 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
|
|