ban Twitch spam bots

By Gav on May 01, 2014

This is a very very very simple few lines of code to just ban the spam bots from twitch that post short urls followed by a sentence.

This is not 100% guaranteed to catch every one of them but over the past few days looking at there url's I think this is most of them, Just comment or add them yourself.

on *:text:*x.co*:#channelname:{
  msg $chan .timeout $nick 600
}

on *:text:*bit.do*:#channelname:{
  msg $chan .timeout $nick 600
}

on *:text:*goo.gl*:#channelname:{
  msg $chan .timeout $nick 600
}

on *:text:*tinyurl.com*:#channelname:{
  msg $chan .timeout $nick 600
}

on *:text:*clck.ru*:#channelname:{
  msg $chan .timeout $nick 600
}

on *:text:*bit.ly*:#channelname:{
  msg $chan .timeout $nick 600
}

on *:text:*j.mp*:#channelname:{
  msg $chan .timeout $nick 600
}

Comments

Sign in to comment.
Gav   -  May 01, 2014

Did not know you could not edit the snippit itself,

anyway here is another one..

on *:text:*cutt.us*:#channelname:{
  msg $chan .timeout $nick 600
}
Nos  -  May 01, 2014
on *:TEXT:$($+(*,cutt.us,*)):<#channelname>:{
  msg $chan .timeout $nick 600
} 
Nos  -  May 01, 2014
on @*:TEXT:*:#:{
  if ($regex($1-,/(cutt.us|spam|spam|spam)\b/iS)) { 
    ban -k $chan $nick 6 spammer
  }
} 
Nos  -  May 01, 2014
msg $chan .timeout $nick 600 

change to

ban -k $chan $nick 6 spammer 

for kick ban

Nos  -  May 03, 2014

Image

Yawhatnever  -  May 03, 2014

The edit button is on the top right, next to the like button. You have to mouseover to see it.

Yawhatnever  -  May 03, 2014

@Nos
The snippet title says this is for Twitch. Twitch has no modes (including bans) and no /KICK command. Twitch commands are sent in a PRIVMSG to the channel and are prefixed with a slash or dot [/.] - in other words, the commands in the snippet were correct to begin with.

$+(,cutt.us,) evaluates to "cutt.us", which is exactly the same as the match that was already being used. Besides making the event shout (TEXT vs text) and adding some around the channel match section of the event to confuse noobs, I have no idea what you were trying to accomplish with that post.

Also, in your haste to show off you forgot to escape the \dot in your regex (which should really be in the matchtext section of the event, instead of using a * wildcard match and an if ($regex()) { }). Some form of explanation as to what any of your responses mean/do and the benefits of using one method over another would probably be useful to anyone who visits this page, since this snippet contains examples of the simplest possible on text events; anyone coming here for help will likely have no idea what they're looking at. This is especially true for the regex example. Explaining why you ended the expression with \b, or the significance of the @ prefix on the event would be a good place to start.

Nos  -  May 04, 2014

ehm
@Yawhatnever so how true???

Nos  -  May 04, 2014

whether such

on *:TEXT:$($+(*,cutt.us,*)):#channelname:ban -k $chan $nick 6 spammer 

or

on @$*:TEXT:/(cutt.us|word|word|word|word|word)\b/iS:#channelname:ban -k $chan $nick 6 spammer 
Nos  -  May 04, 2014

@Yawhatnever : please post the code you thought was right Image

Yawhatnever  -  May 04, 2014

@Nos
Neither of those are correct for twitch, since you're still using /ban which won't work there.

I still don't know why you're using a dynamic matchtext in the wildcard match (the top one). Using "$($+(,cutt.us,))" does exactly the same thing as if you had put "cutt.us". It's complicating an otherwise simple example and gaining no benefit.

I would lean towards the regex example, with a few changes:

on @$*:text:/\b(\Qcutt.us\E|\Qexample.com\E|\Qstring_three\E|\Qstring_four\E)\b/iS:#channelname:msg # .timeout $nick 600

Explanation:

  • The @ prefix causes the event to only trigger while you have op.
  • The $ prefix indicates that the matchtext is a regular expression.
  • The \Q\E escape is used to escape regex special characters (in the example the only special character used is the dot). http://www.regular-expressions.info/characters.html
  • Added another \b anchor to the front of the group to prevent something like 'mycut.us' matching 'cut.us'. http://www.regular-expressions.info/wordboundaries.html
  • The /i and /S modifiers at the end of the expression signal mIRC to use case-insensitive matching and strip special control characters, respectively. Twitch already removes most of those characters (e.g. colors, bold, underline) before the client ever sees the message, so the latter may be redundant.

For anyone looking at this expression and thinking it looks a lot more intimidating than using a plain wildcard match on text event for each new site, it's actually fairly simple once you know how it works. It uses three main regex concepts: alternation, escaping (special characters), and word boundaries. I've linked explanations to two of those concepts already. Here's the third: http://www.regular-expressions.info/alternation.html

Hope this helps clarify for anyone reading.

Nos  -  May 04, 2014

@Yawhatnever : Your code is very good

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.