resp.on('data', function(chunk) { var str = chunk.slice(chunk.search(/\<.*thick.*\>/),chunk.search('thick')); var str2 = str.slice(str.search('value'), str.search('style')); var str3 = str2.slice(str2.search('\"')+1, str2.search('\%')); bot.pm('Volume: ' +str3+ '%', userid); });
bot.pm('/botdown --> I stop DJing\n\n', userid, function(){ bot.pm('/skip --> if DJing, I skip the current song\n\n', userid, function(){ bot.pm('/stats --> I display some stats\n\n', userid, function(){ bot.pm('/info --> I\'ll pm you this list of commands\n\n', userid); }) }) })
function pmCMD(name, userid) { // chaining callbacks to pm in correct order // apparently newlines are not supported by chat window :( bot.pm('These are the commands I understand:\n\n', userid, function(){ bot.pm('/hello --> I say hello to you\n\n', userid, function(){ bot.pm('/votes --> the vote count for current song\n\n', userid, function(){ bot.pm('/escort --> I\'ll remove you from the stage after your next song finishes\n\n', userid, function(){ bot.pm('/botup --> I get up and DJ\n\n', userid, function(){ bot.pm('/botdown --> I stop DJing\n\n', userid, function(){ bot.pm('/skip --> if DJing, I skip the current song\n\n', userid, function(){ bot.pm('/stats --> I display some stats\n\n', userid, function(){ bot.pm('/info --> I\'ll pm you this list of commands\n\n', userid); }) }) }) }) }) }) }) }); console.log('Pmmed ' +name+ '(' +userid+ ')'); }
bot.on('pmmed', function (data) { console.log('\nIncoming personal message:', data); if(isAdmin(data.senderid)) { adminCommands(data.text, PM, data.senderid); } else { bot.pm("Thanks for sharing!", data.senderid); } });
// 8888888888 888 888 888b 888 .d8888b. d8b // 888 888 888 8888b 888 d88P Y88b 88P // 888 888 888 88888b 888 888 888 8P // 8888888 888 888 888Y88b 888 888 " .d8888b // 888 888 888 888 Y88b888 888 88K // 888 888 888 888 Y88888 888 888 "Y8888b. // 888 Y88b. .d88P 888 Y8888 Y88b d88P X88 // 888 "Y88888P" 888 Y888 "Y8888P" 88888P' function upTime(data, pm) { var timeNow = Date.now(); var upTime = timeNow - startTime; var utHours = Math.floor(upTime / (1000 * 3600)); var utMins = Math.floor((upTime % (3600 * 1000)) / (1000 * 60)); var utSecs = Math.floor((upTime % (60 * 1000)) / 1000); if (reLogins > 0) var relogins = " and gracefully re-logged on due to internet / tt.fm outages " + reLogins + " time(s). Was last down for " + botDowntime + " second(s)"; else var relogins = ""; if (utHours > 0) { if (pm) bot.pm("I've been slaving away for " + utHours + " hour(s) " + utMins + " minute(s) and " + utSecs + " second(s) now!" + relogins, data.senderid); else bot.speak("/me has been slaving away for " + utHours + " hour(s) " + utMins + " minute(s) and " + utSecs + " second(s) now!" + relogins); } else if (utMins > 0) { if (pm) bot.pm("I've been slaving away for " + utMins + " minute(s) and " + utSecs + " second(s) now!" + relogins, data.senderid); else bot.speak("/me has been slaving away for " + utMins + " minute(s) and " + utSecs + " second(s) now!" + relogins); } else { if (pm) bot.pm("I've been slaving away for " + utSecs + " second(s) now!" + relogins, data.senderid); else bot.speak("/me has been slaving away for " + utSecs + " second(s) now!" + relogins); } }
bot.roomRegister(ROOMID, function (data) { if (data && data.success) { console.log("[ I'M BACK!!!! WEEEEEEEeeeeeeeeee!!! ]"); botDowntime = (Date.now() - botDownUTCtime) / 1000; reLogins += 1; // Increment the reLogin counter. bot.pm("NET/TT.FM WAS DOWN on " + botDownDATEtime + " for " + botDowntime + " second(s)", ADMIN); console.log("[ NET/TT.FM WAS DOWN on " + botDownDATEtime + " for " + botDowntime + " second(s) ]"); // Here you can re-initialize things if you need to, like re-loading a queue // ... } });
bot.pm('/escort --> I\'ll remove you from the stage after your next song finishes\n\n', userid, function(){ bot.pm('/botup --> I get up and DJ\n\n', userid, function(){ bot.pm('/botdown --> I stop DJing\n\n', userid, function(){ bot.pm('/skip --> if DJing, I skip the current song\n\n', userid, function(){ bot.pm('/stats --> I display some stats\n\n', userid, function(){ bot.pm('/info --> I\'ll pm you this list of commands\n\n', userid); }) }) }) }) })
bot.on('registered', function (data){ if (shutUp == false) { if (data.user[0].userid == configJSON.botinfo.userid) { //chillbot announces himself //bot.speak('Never fear Chillout Tent Denizens! I, ' +data.user[0].name+ ' your faithful chillbot, have arrived!') } else if (data.user[0].userid == configJSON.botinfo.masterid) { //if the master arrives announce him specifically //bot.speak('Dearest Subjects '+configJSON.botinfo.mastername+', your friendly neighborhood Dictator of Chill has arrived!') } else if (data.user[0].userid == configJSON.botinfo.creatorid) { //if the creator arrives announce him specifically bot.speak('Tent denizens say hello to '+configJSON.botinfo.creatorname+' - the Tents esteemed Creator! *golf clap*') } else if (!admincheck(data.user[0].userid)){ //TODO: once iPhone PM is sorted out, maybe this should be a PM to newly arrived people? ////bot.speak('Welcome '+data.user[0].name+'! Type /help to learn how to control me.'); //welcome the rest bot.pm('Welcome to The Chillout Tent '+data.user[0].name+'! Type /genre to learn more about the musical style we play here. Happy chilling!', data.user[0].userid); //welcome the rest } } });
function iter (item, callback) { if (type.match('pm')) { bot.pm(item, userid, function (){ callback(); }); } else { bot.speak(item, function (){ callback(); }); } }
bot.pm('These are the commands I understand:\n\n', userid, function(){ bot.pm('/hello --> I say hello to you\n\n', userid, function(){ bot.pm('/votes --> the vote count for current song\n\n', userid, function(){ bot.pm('/escort --> I\'ll remove you from the stage after your next song finishes\n\n', userid, function(){ bot.pm('/botup --> I get up and DJ\n\n', userid, function(){ bot.pm('/botdown --> I stop DJing\n\n', userid, function(){ bot.pm('/skip --> if DJing, I skip the current song\n\n', userid, function(){ bot.pm('/stats --> I display some stats\n\n', userid, function(){ bot.pm('/info --> I\'ll pm you this list of commands\n\n', userid); }) }) }) }) }) }) }) });
sdb2.on('row', function(row){ if (type.match('pm')) bot.pm('Most Popular DJ: ' +row.username, userid); else bot.speak('Most Popular DJ: ' +row.username); });
resp.on('data', function(chunk) { var str = chunk.slice(chunk.search(/\<.*thick.*\>/),chunk.search('thick')); var str2 = str.slice(str.search('value'), str.search('style')); var str3 = str2.slice(str2.search('\"')+1, str2.search('\%')); var timenow = new Date().getTime(); if (dir.match(/\/vol\+/)) { newvol = parseInt(str3) + 10; if (newvol > 90) newvol = 90; } else if (dir.match(/\/vol\-/)) { newvol = parseInt(str3) - 10; if (newvol < 0) newvol = 0; } // otherwise, we are being lazy and using dir to pass in a value else { console.log('Passed in value: ' +dir); if (dir.match(/^\/vol*/)) { console.log('matched "vol..."'); var subs1 = dir.slice(4); var subs2 = subs1.trim(); dir = subs2; } newvol = parseInt(dir); if (isNaN(newvol)) return; } if (userid == null) bot.speak('Changed Volume from ' +str3+ '% to ' +newvol+ '%', userid); else bot.pm('Changed Volume from ' +str3+ '% to ' +newvol+ '%', userid); var post_data = qs.stringify({ volume: newvol + '%', '_': timenow }); var options = { host: 'voltron', port: 80, path: '/internal/audioControl/', method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': post_data.length } }; var req2 = http.request(options, function (resp){ resp.setEncoding('utf8'); resp.on('data', function (chunk){ console.log('response = |' +chunk+ '|'); }); }); req2.on("error", function(e){ console.log('Got an error: ' +e.message); }); req2.write(post_data+ '\n'); req2.end(); });
bot.playlistAll(function (playlist) { bot.playlistRemove(playlist.list.length - 1); bot.pm('Removed song from list', sender); });
bot.on('pmmed', function (data) { // The content of the message var text = data.text; // The user issuing the message var user = data.userid; // sender var sender = data.senderid; // Does user have permission for bot commands var isAdmin = $.inArray(user, config.botAdminsId) > -1; var found = ''; // Admin check if (isAdmin) { // Anonymous message via bot found = text.match(/^\/(msg)(.+)$/); // Check for anon message if (found) { bot.speak(found[2]); } // Simple Commands switch(text) { case '/go': startBotDJ(); break; case '/stop': bot.remDj(); // Random dj name here bot.speak('I\'m stepping why don\'t _____ start djing'); break; case '/skip': bot.skip(); bot.speak('Thank you. That song was borrring.'); break; case '/addsong': bot.pm('Song Added', sender); bot.playlistAdd(bot.song.songId); bot.snag(); break; case '/playlist': bot.playlistListAll(function (playlist) { console.log(playlist); }); break; case '/playlist create': //console.log(text); break; case '/remove': // Remove the current song from next queue bot.playlistAll(function (playlist) { bot.playlistRemove(playlist.list.length - 1); bot.pm('Removed song from list', sender); }); //bot.playlistRemove(bot.song.songId); break; case '/debug': console.log(data); break; default: //bot.speak('I don\' understand the command @' + user + '.'); //console.log(text) break; } } });
bot.on('speak', function (data) { // Get the data var name = data.name; var text = data.text; var user = data.userid; /** if bot name is mentioned **/ if (text.match('/mods')) { if (moderatorList) bot.speak('Mods: '+moderatorList+''); } if (text.match('/djs')) { if (dJList) bot.speak('DJs: '+dJList+''); } /** if bot name is mentioned **/ if (text.match(settings.BOT_NAME)) { bot.speak('That\'s my name, don\'t wear it out!'); } /** Room Rules **/ if (text.match(/^(?:\*|\/)rules$/)) { bot.speak('See '+settings.ROOM_RULES_URL+' for the room rules.'); } /** Song Information **/ if (text.match(/^\/songinfo$/)) { bot.roomInfo(true, function(data) { var current_song = data.room.metadata.current_song; if (current_song) { var songId = current_song._id; var songAlbum = current_song.metadata.album; var songGenre = current_song.metadata.genre; var songName = current_song.metadata.song; } if (settings.DEBUG_LOGS) { console.log('---- BEGIN CURRENT SONG METADATA --------------------'); if (current_song) { console.log(current_song.metadata) } else { console.log('No song is playing.');} console.log('---- END CURRENT SONG METADATA --------------------'); } current_song ? bot.speak(':notes: "'+songName+'" :cd: Album: '+songAlbum+' :radio: Genre: '+songGenre+'') : bot.speak(':exclamation: No song is playing.'); }); } //end songinfo /** Look in Moderators array or room mods to see if chatting with an admin. If chatting with an admin, allow user to moderate. **/ if (settings.BOT_MODERATORS_ARRAY.indexOf(user) >= 0||moderatorList.indexOf(user) >= 0) { /** Update Bot's DJ Queue - push playing song to top of queue **/ if (text.match(/^\*top$/)) { bot.roomInfo(true, function(data) { var song = data.room.metadata.current_song._id; var songName = data.room.metadata.current_song.metadata.song; if (song) { bot.playlistAdd(song); } bot.speak(''+songName+' - to the top you go!'); }); } /** fart **/ if (text.match(/^poop$/)) { bot.speak('feart.'); bot.snag(); } /** Disconnect from Turntable.fm **/ if (text.match(/^\/die$/)) { bot.speak('/me dies tragically.'); bot.close(); //fixme } /** Get DJ's Playlist **/ if (text.match(/^\/playlist$/)) { if (settings.DEBUG_LOGS) { bot.pm('Okay, '+name+'. Check log for playlist.',user); bot.playlistAll(function (data) { console.log(data); }); } } if (text.match(/^\/votes$/)) { bot.roomInfo(true, function(data) { if (settings.DEBUG_LOGS) { console.log('---- BEGIN ROOM DATA --------------------'); console.log(data.room); console.log('---- END ROOM DATA --------------------'); } var room = data.room; var upvotes = room.metadata.upvotes; var downvotes = room.metadata.downvotes; var listeners = room.metadata.listeners; var djcount = room.metadata.djcount; bot.speak(':musical_note: :thumbsup:'+upvotes+' :thumbsdown: '+downvotes+''); bot.speak(':man:: '+listeners+' :hash: dj\'s: :'+djcount+':'); }); } if (text.match(/^\/votelog$/)) { bot.roomInfo(true, function(data) { if (settings.DEBUG_LOGS) { console.log('---- BEGIN ROOM DATA --------------------'); console.log(data.room); console.log('---- END ROOM DATA --------------------'); } var room = data.room; var upvotes = room.metadata.upvotes; var downvotes = room.metadata.downvotes; var listeners = room.metadata.listeners; var djcount = room.metadata.djcount; var creatorname = room.metadata.creator.name; var currentdj = room.metadata.current_dj; var vote_log = room.metadata.votelog; var current_song = room.metadata.current_song; if (current_song) { var songId = current_song._id; var songAlbum = current_song.metadata.album; var songGenre = current_song.metadata.genre; var songName = current_song.metadata.song; } if (vote_log) { //todo /** ---- BEGIN VOTELOG DATA -------------------- [ [ '4f9b545caaa5cd2af400022f', 'up' ] ] ---- END VOTELOG DATA -------------------- **/ } if (settings.DEBUG_LOGS) { console.log('---- BEGIN VOTELOG DATA --------------------'); console.log(vote_log); console.log('---- END VOTELOG DATA --------------------'); } /** Show Upvotes, Downvotes for the current song. Show listener count, DJ count. **/ bot.speak(':musical_note: :thumbsup:'+upvotes+' :thumbsdown: '+downvotes+''); bot.speak(':man:: '+listeners+' :hash: dj\'s: :'+djcount+':'); }); } } //end if name in settings.BOT_MODERATORS_ARRAY - end admin chat section }); //end on bot speak.
bot.on('pmmed', function (data) { /** we have to get the variables again **/ var name = data.name; var sender = data.senderid; var text = data.text; var user = data.userid; /** Test for Bot Responsiveness **/ if (text.match(/^hi$/)) { bot.pm('Hey! How are you ?',sender); bot.pm('I\'m just glad to have somebody to talk to.',sender); } if (text.match(/^test$/)) { //if (moderatorList.indexOf(user) >= 0) { if (settings.BOT_MODERATORS_ARRAY.indexOf(user) >= 0||moderatorList.indexOf(user) >= 0) { bot.pm('hi mod',sender); } else { bot.pm('hi user '+user+'',sender); } } /** Look in Moderators array to see if private messaging (PM) with an admin. If in PM with an admin, allow user to moderate via PM. **/ if (settings.BOT_MODERATORS_ARRAY.indexOf(user) >= 0||moderatorList.indexOf(user) >= 0) { /** Am I a bot admin? **/ if (text.match(/^\/botadmin$/)) { bot.pm('Yes, you\'re my admin.',sender); } /** Make Bot DJ if spot is open **/ if (text.match(/^\/dj$/)) { bot.pm('Okay.',sender); bot.addDj(); } /** Make Bot quit DJ'ing **/ if (text.match(/^\/dj off$/)) { bot.pm('Okay.',sender); bot.remDj(); } /** Upvote Current Song **/ if (text.match(/^\/upvote|up$/)) { bot.bop(); } /** Downvote Current Song **/ if (text.match(/^\/downvote|down$/)) { bot.vote('down'); } /** Skip Current Song if bot is DJ'ing **/ if (text.match(/^\/skip$/)) { bot.pm('Gonna skip this song.',sender); bot.skip(); } /** Snag the Song Currently Playing **/ if (text.match(/^\/feart|\/snag$/)) { bot.pm('Gonna heart this song',sender); bot.roomInfo(true, function(data) { var song = data.room.metadata.current_song._id; var songName = data.room.metadata.current_song.metadata.song; bot.snag(); bot.playlistAdd(song); }); } //end snag } });
bot.on('speak', function (data) { if (shutUp == false) { if (data.text.match(/^\/hello$/)) { //bot.speak('Hey! How are you '+data.name+' ?'); } if (data.text.match(/^\/help$/)) { //TODO: make this give MODs the FULL list if (admincheck(data.userid) === true) { // Give MODs the full BOT command list bot.pm('My current MOD command list is maintained here: http://chillout-tent.wikispaces.com/Bot+Commands/ - Questions or Suggestions? hit up KJC and remember to check for new updates!', data.userid); } else { //bot.speak('My current command list is /hello, /help, /rules, /video, /genre, /queue, /props, /warn, /chillbot. Plus a few hidden ones ;) remember to check for new updates!', data.userid); } } if (data.text.match(/^\/chillbot$/)) { bot.speak('Chill BOT v6.6.6 \n\r Coded by: Kim Jung Chill \n\r Acquire your own at https://github.com/rrxtns/Chillout-Tent-bot'); } if (data.text.match(/^\/rules$/)) { bot.speak('Its our room, and our rules..\n\r Suck it up cupcake. \n\r Your room moderators are: well, the best!'); } if (data.text.match(/^\/tasha$/)) { bot.speak(':heart: FREE TASHA! FREE TASHA! FREE TASHA! :heart:'); } if (data.text.match(/^\/lunch$/)) { bot.speak('Enjoy your :fork_and_knife: '+data.name+' cya l8r!'); } if (data.text.match(/^\/genre$/)) { bot.speak('We Play Downtempo, NuJazz, electro-swing & Triphop. DJ queue list and *MUSICAL STYLE GUIDANCE HERE*: http://chillout-tent.wikispaces.com/'); } if (data.text.match(/^\/starve$/)) { bot.speak('NO RICE FOR YOU '+data.name+'!!'); } if (data.text.match(/^\/queue$/)) { bot.speak('@'+data.name+' the DJ queue can be found here: http://chillout-tent.wikispaces.com/DJ_list'); } if (data.text.match(/^\/friday$/)) { bot.speak('Yay, its mother chillin\' FRIDAY!! :joy:'); } if (data.text.match(/^\/drink$/)) { bot.speak('/me hands '+data.name+' a chilled adult beverage :beer:'); } if (data.text.match(/^\/smoke$/)) { bot.speak('Now '+data.name+' you do realize that smokings bad m\'kay? :no_smoking:'); } if (data.text.match(/^\/warn$/)) { bot.speak('This track is off genre, skip the song or be removed!'); } if (data.text.match(/^\/rich$/)) { bot.speak("I don't think you realize how rich he really is. In fact, I should put on a monocle. /monocle"); } if ((data.text.match(/props/i)) && (data.userid != configJSON.botinfo.userid)) { var rndm = Math.floor(Math.random() * 10); bot.speak(data.name + ' says ' + props[rndm]); } // if (data.text.match(/^\/pm$'/)) { // console.log('I was PM\'d', data); // bot.speak('Hey there! Type "/help" for a list of commands.', data.userid); // } if (data.text.match(/^\/dance$/)) { console.log(timeStamp() + ' got request to dance'); bot.speak('Sorry, bot bopping is disabled until autobop rules for bots can be implemented'); // bot.bop(); } if (data.text.match(/^\/bop$/)) { console.log(timeStamp() + ' got request to bop'); bot.speak('Sorry, bot bopping is disabled until autobop rules for bots can be implemented'); // bot.bop(); } if (data.text.match(/^\/cheer$/)) { console.log(timeStamp() + ' got request to cheer'); bot.speak('Sorry, bot bopping is disabled until autobop rules for bots can be implemented'); //bot.bop(); } if (data.text.match(/^\/meeting$/)) { var rndm = Math.floor(Math.random() * 10); bot.speak(meeting[rndm]); } //TODO: this seems to be removing djs instead of just voting down // if (data.text.match(/^\/boo$/)) { // console.log('got request to boo'); // bot.vote('down'); // } // Respond to "/video" command if (data.text.match(/^\/video$/)) { bot.roomInfo(true, function(data) { var queryResponse = ''; var currSong = data.room.metadata.current_song.metadata.song; var currArtist = data.room.metadata.current_song.metadata.artist; currSong = currSong.replace(/ /g,"_"); currArtist = currArtist.replace(/ /g,"_"); currSong = currSong.replace(/\./g,""); currArtist = currArtist.replace(/\./g,""); var options = { host: 'gdata.youtube.com', port: 80, path: "/feeds/api/videos?q=" + currArtist + "_" + currSong + "&max-results=1&v=2&prettyprint=true&alt=json" }; console.log(options); http.get(options, function(response) { console.log("Got response:" + response.statusCode); response.on('data', function(chunk) { try { queryResponse += chunk; } catch (err) { bot.speak(err); } }); response.on('end', function(){ var ret = JSON.parse(queryResponse); //if the return is a playlist the JSON is entirely different. For now I am just error handling this. try { bot.speak(ret.feed.entry[0].media$group.media$content[0].url); } catch (err) { bot.speak("Sorry. The return was a playlist. This is unsupported currently."); } }); }).on('error', function(e) { bot.speak("I can't do that Dave: " + e.message); }); }); // END "fetch video" command } //Respond to "/google <query>" if (data.text.match(/^\/google/)) { //chop out the query and parse it var searchQueryArray = data.text.split('/google '); var searchQuery = searchQueryArray[1]; //replace the most common special characters and turn spaces into + searchQuery = searchQuery.replace(/\'/g,"%27").replace(/;/g,"%3B").replace(/#/g,"%23").replace(/@/g,"%40").replace(/&/g,"%26").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/=/g,"%3D").replace(/\+/g,"%2B"); //replace spaces with + searchQuery = searchQuery.split(' ').join('+'); bot.speak("http://lmgtfy.com/?q=" + searchQuery); //returns a link to let me google that for you for both your search and my amusement of delivery method } // End "if NOT commanded to 'shutup' } // End "general bot chatting" });
sdb3.on('row', function(row){ if (type.match('pm')) bot.pm('Most Played Song: ' +row.artist+ ' - ' +row.title, userid); else bot.speak('Most Played Song: ' +row.artist+ ' - ' +row.title); });
function respond(msg, method, receiverid) { bot.pm(msg, receiverid); }
sdb1.on('row', function(row){ if (type.match('pm')) bot.pm('Most Popular Song: ' +row.artist+ ' - ' +row.title+ ' played by ' + row.username+ ' on ' +row.date, userid); else bot.speak('Most Popular Song: ' +row.artist+ ' - ' +row.title+ ' played by ' + row.username+ ' on ' +row.date); });
bot.pm('/stats --> I display some stats\n\n', userid, function(){ bot.pm('/info --> I\'ll pm you this list of commands\n\n', userid); })
bot.roomInfo(false, function(data){ for (var i = 0; i < data.users.length; i++) { if (data.users[i].userid == userid) name = data.users[i].name; } //Respond to "/votes" command if (text.match(/^\/votes$/)) { var up = data.room.metadata.upvotes; var down = data.room.metadata.downvotes; bot.pm('Current song votes - up: ' +up+ ' down: ' +down, userid); } //Respond to "/botup" command else if (text.match(/^\/botup$/)) { console.log(name+ ' wants bot to DJ'); shuffle(function(){ bot.addDj(); bot_dj = 1; }); } //Respond to "/botdown" command else if (text.match(/^\/botdown$/)) { console.log(name+ ' wants bot to stop DJing'); bot.remDj(USERID); bot_dj = 0; } //Respond to "/skip" command else if (text.match(/^\/skip$/)) { console.log(name+ ' wants bot to skip the song'); if (bot_dj == 1) { bot.skip(); bot.speak(name+ ' wants me to skip this song'); } else bot.pm('Sorry, I\'m not the DJ... can\'t skip', userid); } // Respond to "/hello" command else if (text.match(/^\/hello$/)) { bot.pm('Hey! How are you '+name+'?', userid); } //Respond to "/bop" command else if (text.match(/^\/bop$/)) { if (vote_flag == 1) bot.pm('I already voted', userid); else if (data.room.metadata.current_dj == USERID) bot.pm('uh, I\'m the dj... I can\'t vote', userid); else { bot.speak('OK, I\'ll vote for this song '+name); bot.bop(); vote_flag = 1; } } // Respond to "/stats" command else if (text.match(/^\/stats$/)) { stats('pm', name, userid); } // Respond to "/lb" (leaderboard) command else if (text.match(/^\/lb$/)) { leaderboard('pm', name, userid); } // Respond to "/escort" (leaderboard) command else if (text.match(/^\/escort$/)) { console.log('adding ' +name+ ' to escort queue'); escort.push(name); bot.pm('OK ' +name+ ', I\'ll escort you after your next song ends', userid); } ////////// ADMIN COMMANDS ///////////////////////////////////// // TBD: store user rights in db and query for isadmin instead of hardcoding usernames // don't add the current song else if (text.match(/^\/noadd$/) && name.match('benw54')) { noadd = 1; bot.pm('OK, I won\'t add this song', userid); } // commands to control voltron volume else if (text.match(/^\/(unmute|mute)$/) && (name.match('benw54') || name.match('Farmer Maggie') || name.match('Safarry') || name.match('lucasmo'))) { volOnOff(text); } // request voltron's current volume else if (text.match(/^\/vol\?$/) && (name.match('benw54') || name.match('Farmer Maggie') || name.match('Safarry') || name.match('lucasmo'))) { var options = { host: 'voltron', port: 80, path: '/internal/audioControl/' }; var req = http.request(options, function (resp){ resp.setEncoding('utf8'); resp.on('data', function(chunk) { var str = chunk.slice(chunk.search(/\<.*thick.*\>/),chunk.search('thick')); var str2 = str.slice(str.search('value'), str.search('style')); var str3 = str2.slice(str2.search('\"')+1, str2.search('\%')); bot.pm('Volume: ' +str3+ '%', userid); }); resp.on('error', function (error) { console.log('Got an error ' +error); }); }); req.end(); } else if (text.match(/^\/vol(\+|\-)$/) && (name.match('benw54') || name.match('Farmer Maggie') || name.match('Safarry') || name.match('lucasmo'))) { volRelative(text, userid); } /////////////////////////////////////////////////////////////// //Respond to "/info" command // or give info for any other PMs, // what else would the bot say? :) else // if (text.match(/^\/info$/)) { pmCMD(name, userid); } });