mIRC Home    About    Download    Register    News    Help

Print Thread
#213636 04/07/09 12:52 PM
Joined: May 2009
Posts: 28
B
Ameglian cow
OP Offline
Ameglian cow
B
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
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
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

Last edited by genius_at_work; 04/07/09 03:59 PM.
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Why not do:
Code:
on @*:TEXT:*:#: {
  var %punct = $len($regsubex($1-,/[:punct:]/Si,))
  if (%punct > 50) { kick # $nick used %punct punctuation marks to flood }
}

Tomao #213668 05/07/09 12:59 AM
Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
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 }
}

Last edited by Wims; 05/07/09 01:01 AM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #213669 05/07/09 02:43 AM
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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.

Tomao #213670 05/07/09 03:57 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
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.

Tomao #213671 05/07/09 05:22 AM
Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
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.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
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.:
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 ? }


Joined: May 2009
Posts: 28
B
Ameglian cow
OP Offline
Ameglian cow
B
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
H
Hoopy frood
Offline
Hoopy frood
H
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)
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
    }

  }
}


Link Copied to Clipboard