mIRC Homepage
Posted By: Babystone punctuation flood - 04/07/09 12:52 PM
Hi all , anyone there can help me to write a code for punctuation flood?? Thanks

Posted By: genius_at_work Re: punctuation flood - 04/07/09 03:53 PM
Code:

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
Posted By: Tomao Re: punctuation flood - 04/07/09 11:39 PM
Why not do:
Code:
on @*:TEXT:*:#: {
  var %punct = $len($regsubex($1-,/[:punct:]/Si,))
  if (%punct > 50) { kick # $nick used %punct punctuation marks to flood }
}
Posted By: Wims Re: punctuation flood - 05/07/09 12:59 AM
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 :
Code:
on @*:TEXT:*:#: {
if ($regex($1-,/[:punct:]/gSi) > 50) { kick # $nick used %punct punctuation marks to flood }
}
Posted By: Tomao Re: punctuation flood - 05/07/09 02:43 AM
Wims, you made a couple of overlooked flaws
Quote:
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.
Posted By: RusselB Re: punctuation flood - 05/07/09 03:57 AM
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.
Posted By: Wims Re: punctuation flood - 05/07/09 05:22 AM
I know about the [ ], this flaw is your, but this will teach me how to copy paste a code smile and yes, it should be $v1.
Posted By: Horstl Re: punctuation flood - 05/07/09 05:42 AM
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.:
Code:
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:
Code:
  if ($count($1-,.,!,?) > 20) { echo -a Message contains $v1 chars out of: . ! or ? }

Posted By: Babystone Re: punctuation flood - 05/07/09 05:55 AM
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
Posted By: Horstl Re: punctuation flood - 05/07/09 06:19 AM
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)
Code:
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
    }

  }
}
© mIRC Discussion Forums