mIRC Home    About    Download    Register    News    Help

Print Thread
punctuation flood #213636 04/07/09 12:52 PM
Joined: May 2009
Posts: 28
B
Babystone Offline OP
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


Re: punctuation flood [Re: Babystone] #213645 04/07/09 03:53 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
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.
Re: punctuation flood [Re: genius_at_work] #213666 04/07/09 11:39 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
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 }
}

Re: punctuation flood [Re: Tomao] #213668 05/07/09 12:59 AM
Joined: Jul 2006
Posts: 3,702
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,702
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.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: punctuation flood [Re: Wims] #213669 05/07/09 02:43 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
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.

Re: punctuation flood [Re: Tomao] #213670 05/07/09 03:57 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
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.

Re: punctuation flood [Re: Tomao] #213671 05/07/09 05:22 AM
Joined: Jul 2006
Posts: 3,702
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,702
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.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: punctuation flood [Re: Babystone] #213672 05/07/09 05:42 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
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 ? }


Re: punctuation flood [Re: Horstl] #213673 05/07/09 05:55 AM
Joined: May 2009
Posts: 28
B
Babystone Offline OP
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

Re: punctuation flood [Re: Babystone] #213674 05/07/09 06:19 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
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
    }

  }
}