mIRC Homepage
Posted By: Moose Repeated character posts kicker - 05/01/13 04:09 AM
I am not sure where to start on this script. The problem I am facing is that the channel I moderate is associated with a Ustream broadcast and occasionally the broadcaster will switch on his tts. Invariably, despite countless admonishments not to, chatters will try to play with the tts; something that gets old very quickly. Unfortunately, the broadcaster wants the mods to be excessively gentle when it comes to doling out punishments so we can't just kick everyone who acts up.(although he will allow short time outs)

Essentially what I would like to do is write a script that can detect when someone makes a post that consists of only one or two types of characters such as sssssssssssssssssssssssss or !!!!!!!!!!!!!!11!!!!1!!! or lolol...ololol etc and take action to reprimand a poster for making that kind of post. I could probably figure out how to make something that would detect posts that are primarily made up of symbols... but I don't even know where to begin on something that measures how varied the characters in a post are. So... any suggestions?

Thanks in advance,
Moose


edit: I found another kind of behavior I'd like to have my bot detect. I've seen scripts that detect two repeated posts in a row, but is there anything that can stop something like this: <Rogbull> Thunt, come back! Thunt, come back! Thunt, come back! Thunt, come back! Thunt, come back! ?

Again, I'd appreciate any advice you can give me.


Posted By: sparta Re: Repeated character posts kicker - 05/01/13 09:47 AM
You can go here and look for a addon.

http://www.mircscripts.org/

a swear/bad language kicker maybe solve your first problem. The next one can be solved with a repeat kicker of some sort.
Posted By: Tomao Re: Repeated character posts kicker - 05/01/13 05:51 PM
Quote:
a script that can detect when someone makes a post that consists of only one or two types of characters such as sssssssssssssssssssssssss or !!!!!!!!!!!!!!
To kick for repeated letter abuse, you can do this with regex:
Code:
on @$*:text:/(.)\1{5}/:#:{
  kick # $nick Repeated characters detected!
}
This will kick repeated, same letters or characters that exceed more than 5 times.
Posted By: Moose Re: Repeated character posts kicker - 05/01/13 10:44 PM
Originally Posted By: Tomao
To kick for repeated letter abuse, you can do this with regex:
Code:
on @$*:text:/(.)\1{5}/:#:{
  kick # $nick Repeated characters detected!
}
This will kick repeated, same letters or characters that exceed more than 5 times.


That seems to be more what I'm looking for as it's fairly light on coding, but the bot I want to incorporate it into tends to have such things nested into a single on *:text:*:#: trigger. Is there a way to separate the regex from that snippet so that I could incorporate it into an alias? It definitely seems like a more elegant solution than what I was able to put together. Would there be a way to use regex to catch something like someone repeating "lolololol" or "soi soi soi soi" (both are common abuses of tts when it's on in our channel)? Also, is there a way to catch chopped text (t h i s i s c h o p p e d) with a regex? My way works, but only if the whole post is chopped and it takes up a lot of lines. I also have been unable to find any scripts that catch repetition within a single post such as: "Thunt, come back! Thunt, come back! Thunt, come back! Thunt, come back! Thunt, come back!" The only solution to that I could think of would be a tokenized version of the alias I included below that would check how many times the first, second, and third words show up in the post and compare them to how many total words are in the text.


Code:
 alias repeatstring {
  echo repeatstring 
  ;syntax repeatstring nick-to-check post
  var %rs-len $len($2-)
  ;The following three lines pull the first three characters
  ;in the post to compare later
  var %rs-chr1 = $left($2-,1) 
  var %rs-chr2 = $mid($2-,2,1)
  var %rs-chr3 = $mid($2-,3,1)
  var %rs-post = $remove($2-,$chr(32))
  var %rs-ns-len = $len(%rs-post)
  ;The line below counts the number of times the first 
  ;three characters in the post show up throughout the post.
  ;This will be compared to the overall length of the post 
  ;to see what percentage of the post is composed of this
  ;handful of letters.
  ;The line that calls this alias is only triggered by 
  ;posts over 10 characters long
  var %rs-ct1 = $count(%rs-post,%rs-chr1,%rs-chr2,%rs-chr3)
  var %rs-cns-len $calc(%rs-ns-len * .9)

  if (%rs-ct1 >= %rs-cns-len) echo repeated string caught
  ;The following segment is designed to catch chopped text
  ;where there are almost an equal number of spaces to
  ;characters
  var %rs-spaces $count($2-,$chr(32))
  var %rs-c-len $calc(%rs-len * .4)
  echo spaces %rs-spaces len %rs-len
  if (%rs-spaces > %rs-c-len) echo chopped text caught
  echo pre tts-abuse check %rs-spaces %rs-len %rs-c-len %rs-ct1 %rs-ns-len %rs-cns-len

  if (%rs-ct1 >= %rs-cns-len) echo repeated string caught
  if ((%rs-spaces > %rs-c-len) || (%rs-ct1 >= %rs-cns-len)) {
    echo tts abuse caught
    if (%tts-on == 1) {
      echo tts is on
      set -u600 %tts-on 1
      set -u900 %tts-abuse $calc(%tts-abuse + 1)
      echo tts abuse increas %tts-abuse
      if (%tts-abuse == 1) msg $chan Please don't play with the text to speech.
      if (%tts-abuse == 2) msg $chan Don't play with the text to speech.
      if (%tts-abuse == 3) msg $chan Do NOT play with the text to speech. Anyone who continues to play with the Text to Speech will receive a timeout.
      if (%tts-abuse > 3) {
      ;This section gives increasingly lengthy timeouts 
      ;for tts abuse, other actions such as mod given 
      ;timeouts serve to increment the %tts-abuse variable
      ;upwards.
        var %time1 = $calc((%tts-abuse - 3) * 30))
        msg $chan $1 has been given a %time1 second timeout for abusing the text to speech.  Everyone who plays with the text to speech will be given a time out from this point on.
        mode $chan +b-v ~q: $+ $address($nick,2) $nick 
        timer 1 %time1 mode $chan -b ~q: $+ $address($nick,2)
        timer 1 %time1 if ($left($nick,9) != ustreamer) pvoice 1 $chan $nick 
        timer 1 %time1 msg $nick Your timeout is now over.
        ;banadd is an alias that adds the chatters ip to
        ;a hash table that keeps them from being voiced
        ;if they part and rejoin the chat.
        banadd $address($nick,2) %time1
      }

    }
  }
}


I know it's inefficient and a bit ugly, but I really do appreciate any feedback you can give me, and thanks for the advice so far.
© mIRC Discussion Forums