Skip to content

Instantly share code, notes, and snippets.

@technobly
Last active December 17, 2015 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save technobly/5674717 to your computer and use it in GitHub Desktop.
Save technobly/5674717 to your computer and use it in GitHub Desktop.
A Turntable.fm bot that stalks a specific user. If they are on, it will find them, and follow them... log the chat in their room to the console. >:| muwhahahaha!!!
// .d8888b. 88888888888 d8888 888 888 d8P 888888b. .d88888b. 88888888888
// d88P Y88b 888 d88888 888 888 d8P 888 "88b d88P" "Y88b 888
// Y88b. 888 d88P888 888 888 d8P 888 .88P 888 888 888
// "Y888b. 888 d88P 888 888 888d88K 8888888K. 888 888 888
// "Y88b. 888 d88P 888 888 8888888b 888 "Y88b 888 888 888
// "888 888 d88P 888 888 888 Y88b 888 888 888 888 888
// Y88b d88P 888 d8888888888 888 888 Y88b 888 d88P Y88b. .d88P 888
// "Y8888P" 888 d88P 888 88888888 888 Y88b 8888888P" "Y88888P" 888
//
// Stalkbot - Copyright (C) 2013 B^Dub - dubbytt@gmail.com - Last update May 31st 2013
//
// A Turntable.fm bot that stalks a specific user.
// If they are on, it will find them, and follow them...
// Also it will log the chat in their room to the console. >:| muwhahahaha!!!
//
// Not to be re-distributed for profit, or sold. Make it free, or die.
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
// This software is best viewed with Sublime Text http://www.sublimetext.com
//
// ASCII GEN http://patorjk.com/software/taag/#p=display&f=Colossal&t=STALKBOT
//------------------------------------------------------------------------------
//--------------------------------------------------------------
// USER SETUP
// ------------------------------------------------------------
var Bot = require('ttapi');
// FIGURE OUT YOUR AUTH, USERID, ROOMID with this tool:
// http://alaingilbert.github.io/Turntable-API/bookmarklet.html
var AUTH = 'xxxxxxxxxxxxxxxxxxxxxxxx';
var USERID = 'xxxxxxxxxxxxxxxxxxxxxxxx';
var ROOMID = 'xxxxxxxxxxxxxxxxxxxxxxxx';
// Double-click on a user's name in their profile to
// find their userid. Or get it like this:
// http://turntable.fm/api/user.get_id?name=B^Dub
var userToStalk = "xxxxxxxxxxxxxxxxxxxxxxxx";
//--------------------------------------------------------------
// LEAVE THIS VARIABLES ALONE :)
//--------------------------------------------------------------
var currentRoom = ROOMID; // Gotta start somewhere, where bot is
var newRoom = ""; // Leave blank, used to follow userToStalk
var bot = new Bot(AUTH, USERID, ROOMID);
// set this to 'true' to see lots and LOTS of debug data :-/
bot.debug = false; // ok you can change this one, if you must!
// 8888888b. 8888888888 d8888 8888888b. Y88b d88P
// 888 Y88b 888 d88888 888 "Y88b Y88b d88P
// 888 888 888 d88P888 888 888 Y88o88P
// 888 d88P 8888888 d88P 888 888 888 Y888P
// 8888888P" 888 d88P 888 888 888 888
// 888 T88b 888 d88P 888 888 888 888
// 888 T88b 888 d8888888888 888 .d88P 888
// 888 T88b 8888888888 d88P 888 8888888P" 888
//
// This will fire after the bot has connected to TT.FM
bot.on('ready', function() {
setInterval(function() { // Run every 10 seconds
bot.roomInfo(false, function(data1) { // Omits song data (extended = false)
currentRoom = data1.room.roomid;
if (data1.success) {
bot.stalk(userToStalk, function(data2) {
if (data2.success && currentRoom != data2.roomId) {
newRoom = data2.roomId;
console.log("Jumping to new room in 3 seconds: " + data2.roomId);
bot.roomDeregister();
setTimeout(function() {
bot.roomRegister(newRoom, function(data3) {
if (data3.success) console.log("Room jump complete!");
});
}, 3000); // end setTimeout
} else if (data2.success && currentRoom == data2.roomId) {
console.log("Currently with user >:|");
} else {
console.log("Waiting to stalk user >:|");
}
}); // end stalk
}
}); // end roomInfo
}, 10000); // end setInterval
}); // end bot.on(ready)
// .d8888b. 8888888b. 8888888888 d8888 888 d8P
// d88P Y88b 888 Y88b 888 d88888 888 d8P
// Y88b. 888 888 888 d88P888 888 d8P
// "Y888b. 888 d88P 8888888 d88P 888 888d88K
// "Y88b. 8888888P" 888 d88P 888 8888888b
// "888 888 888 d88P 888 888 Y88b
// Y88b d88P 888 888 d8888888888 888 Y88b
// "Y8888P" 888 8888888888 d88P 888 888 Y88b
//
// Logs the chat
bot.on('speak', function(data) {
console.log(data.name + ": " + data.text.trim());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment