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.

Last edited by Moose; 05/01/13 10:50 PM.