alaingilbert / Turntable-API

Allows you to create bots for turntable.fm
http://alaingilbert.github.com/Turntable-API/
MIT License
318 stars 97 forks source link

Anti Room Advertising #244

Closed ghost closed 10 years ago

ghost commented 10 years ago

How can I make my bot boot listeners, who posts a link to another room, when they are not a moderator?

alaingilbert commented 10 years ago

Every time someone speak (on('speak'...), verify if there is a link to another room with a regex, if so, then boot him if he is not in a moderator list...

Ho wait, I just rewrote your question.

Izzmo commented 10 years ago

I actually this available on my Mod Tools bookmarklet. Here is the regex I use:

if(window.izzmo.boot_linkers && d.text.search(/https?:\/\/(www.)?(((tt|turntable)\.fm)|(plug\.dj))(\/[a-zA-Z0-9\-\_]*)*\/?/ig) >= 0 && window.izzmo.ttObj.isMod() && !window.izzmo.ttObj.isMod(d.userid)) {
          window.izzmo.socket({
            api: 'room.boot_user',
            roomid: window.izzmo.ttObj.roomId,
            target_userid: d.userid,
            reason: 'Please do not link to other turntable rooms.'
          });

You can hopefully interpret and integrate it into your bot =)

ghost commented 10 years ago

ok, what event handler should I use on top of the code.

Izzmo commented 10 years ago

As @alaingilbert said, use bot.on('speak', function(e) { ... });

ghost commented 10 years ago

Thank You so much.