|
Joined: May 2009
Posts: 28
Ameglian cow
|
OP
Ameglian cow
Joined: May 2009
Posts: 28 |
Hi all , anyone there can help me to write a code for punctuation flood?? Thanks
|
|
|
|
Joined: Oct 2005
Posts: 1,741
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,741 |
on *:TEXT:*:#:{
var %punct = $len($regsubex($strip($1-),/[ a-z0-9]/gi,))
if (%punct > 50) {
echo -a $nick used %punct punctuation marks in $chan
}
}
-genius_at_work
Last edited by genius_at_work; 04/07/09 03:59 PM.
|
|
|
|
Joined: Jul 2007
Posts: 1,129
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
Why not do: on @*:TEXT:*:#: {
var %punct = $len($regsubex($1-,/[:punct:]/Si,))
if (%punct > 50) { kick # $nick used %punct punctuation marks to flood }
}
|
|
|
|
Joined: Jul 2006
Posts: 4,180
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,180 |
Because his code is deleting any char that is not 0-9a-z or space or control code and then count the lenght, your is doing the contrary :p A version with [:punct:] will be :
on @*:TEXT:*:#: {
if ($regex($1-,/[:punct:]/gSi) > 50) { kick # $nick used %punct punctuation marks to flood }
}
Last edited by Wims; 05/07/09 01:01 AM.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Jul 2007
Posts: 1,129
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
Wims, you made a couple of overlooked flaws on @*:TEXT:*:#: { if ($regex($1-,/[[:punct:]]/gSi) > 50) { kick # $nick used $v2 punctuation marks to flood } } If you test it without an additional [], it won't work.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
shouldn't $v2 be $v1, as you're referring to the total number of punctuation marks used, not the 50 that is being compared to.
|
|
|
|
Joined: Jul 2006
Posts: 4,180
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,180 |
I know about the [ ], this flaw is your, but this will teach me how to copy paste a code and yes, it should be $v1.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
Note that [:punct:] will match chars like: ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ If you want to check only "." "!" and "?", you should use genius_at_work's code or create your own character class, e.g.: on @*:TEXT:*:#: {
if ($regex($1-,/[.!?]/g) > 20) {
kick $chan $nick Punctuation flood (your messsage contained $v1 punctuation marks - limit is $v2 $+ ).
}
} This one also won't count chars like ä é or ç. Speaking of count, you could as well use $count: if ($count($1-,.,!,?) > 20) { echo -a Message contains $v1 chars out of: . ! or ? }
|
|
|
|
Joined: May 2009
Posts: 28
Ameglian cow
|
OP
Ameglian cow
Joined: May 2009
Posts: 28 |
on @*:TEXT:*:#: { if ($regex($1-,/[.!?]/g) > 20) { kick $chan $nick Punctuation flood (your messsage contained $v1 punctuation marks - limit is $v2 $+ ). } }
wat should i add if the second offence is a ban? thanks
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
Depends on what banmask you want to use, and if you want to check for a repetition "by nickname", or e.g. "by hostmask". Example: - if the same nickname punct-flooded - a second time - within the last 3 hours (the script will "forget" the first offense after 3 hours) - in the same channel - on the same "network" (more precisely: on the same server connection) ...it will ban the users hostmask (*!*@host.domain) on @*:TEXT:*:#: {
; change "20" to the desired limit
if ($regex($1-,/[.!?]/g) > 20) {
var %count = $v1, %limit = $v2
if ($hget(punctflood,$+($cid,$lf,$chan,$lf,$nick))) {
ban -k $chan $nick 2 banned: repeated punctuation flood ( $+ %count punctiation marks - limit is %limit $+ )
hdel punctflood $+($cid,$lf,$chan,$lf,$nick)
}
else {
kick $chan $nick Punctuation flood (your messsage contained %count punctuation marks - limit is %limit $+ )
hadd -mu10800 punctflood $+($cid,$lf,$chan,$lf,$nick) 1
}
}
}
|
|
|
|
|