You are viewing an older revision! See the latest version

Websockets Server

var askForFans = 0; var fanJoiners = 0; var fanback = 0; var wootSong = 0;

var users = API.getUsers(); var u = users.shift(); var wooting = true; var joining = true;

$("#chat-messages").append("<div class='Gold system'></i><span class='text'>IgorPlugWoot está ativo, digite /comandos para ver os comandos do BOT!</span></div>"); console.log("IgorPlugWoot Online.");

function fanALL() { users = API.getUsers(); u = users.shift();

fALL(u.id); }

function fALL(id){ $.ajax({ url: "http://plug.dj/_/gateway/user.follow_1", type: 'POST', data: JSON.stringify({ service: "user.follow_1", body: [id] }), async: this.async, dataType: 'json', contentType: 'application/json' }).done(function() { if(users.length > 0){ var s = users.shift(); fALL(s.id); console.log("Followed: " + s.username); } }); }

function unfanallroom(id, username){ $.ajax({ url: "http://plug.dj/_/gateway/user.unfollow_1", type: 'POST', data: JSON.stringify({ service: "user.unfollow_1", body: [id] }), async: this.async, dataType: 'json', contentType: 'application/json' }).done(function() { if(users.length > 0){ var us = "";

for(var i in users) { if(i.relationship < 3) { unfanallroom(i.id, i.username); us += i.username + ", "; console.log("Unfollowed : " + i.username); } } } }); }

function follow(id, username, func){ $.ajax({ url: "http://plug.dj/_/gateway/user.follow_1", type: 'POST', data: JSON.stringify({ service: "user.follow_1", body: [id] }), async: this.async, dataType: 'json', contentType: 'application/json' }).done(function() { API.chatLog(func + " : " + username); }); }

function unfollow(id, username){ $.ajax({ url: "http://plug.dj/_/gateway/user.unfollow_1", type: 'POST', data: JSON.stringify({ service: "user.unfollow_1", body: [id] }), async: this.async, dataType: 'json', contentType: 'application/json' }).done(function() { API.chatLog("Unfan : " + username); }); }

API.on(API.USER_FAN, userfanYou); function userfanYou(user) { if(fanback == 1) { follow(user.id, user.username, "Fanback"); } else {} }

function fj(user) { follow(user.id, user.username, "Fan Joiner"); }

function unfj(user) { if(user.relationship < 3) { setTimeout(unfollow(user.id, user.username), 120000); } }

API.on(API.USER_JOIN, userjoin);

function userjoin(user) { if(fanJoiners == 1) { fj(user); unfj(user); } else{} }

function SecondsToHMS(d) { d = Number(d); var h = Math.floor(d / 3600); var m = Math.floor(d % 3600 / 60); var s = Math.floor(d % 3600 % 60); return ((h > 0 ? (h >= 10 ? h : '0' + h): '00') + ':' + (m > 0 ? (m >= 10 ? m : '0' + m): '00') + ':' + (s > 0 ? (s >= 10 ? s : '0' + s): '00') ); }

API.on(API.DJ_ADVANCE, join); join(); function join(obj){ if(joining === true){ $("#dj-button.is-wait").click(); $("#dj-button.is-join").click(); } }

API.on(API.DJ_ADVANCE, woot); woot(); function woot(obj){ if(wooting === true){ $("#woot").click(); } }

function askingFans() { if(askForFans == 1) { API.sendChat(">>>>> Fan For Fan <<<<< Vire meu fan que eu viro de volta"); } else{} }

function command1() { if(askForFans === 0) {askForFans = 1; API.chatLog("Pedido de Fans Ativado!");} else {askForFans = 0; API.chatLog("Pedido de Fans Desativado!");} } function command2() { fanALL();

setTimeout(command3, 180000);

API.chatLog("Fan em todos usuarios da sala!", true); } function command3() { var users = API.getUsers();

for(var i in users) { unfanallroom(i.id, i.username); }

API.chatLog("Unfan em todos usuarios da sala!", true); } function command4() { if(fanJoiners === 0) {fanJoiners = 1; API.chatLog("Fan Joiners Ativado!");} else{fanJoiners = 0; API.chatLog("Fan Joiners Desativado!");} } function command5() { if(fanback === 0) {fanback = 1; API.chatLog("Fan Back Ativado!");} else{fanback = 0; API.chatLog("Fan Back Desativado!");} } function command6() { $.ajax({ type: 'POST', url: 'http://plug.dj/_/gateway/user.set_status_1', contentType: 'application/json', data: '{ "service": "user.set_status_1", "body": ["5"] }' }); API.chatLog("branco"); } function command7() { $.ajax({ type: 'POST', url: 'http://plug.dj/_/gateway/user.set_status_1', contentType: 'application/json', data: '{ "service": "user.set_status_1", "body": ["4"] }' }); API.chatLog("Inativo"); } function command8() { API.setStatus(API.STATUS.WORKING); API.chatLog("Trabalhando"); } function command9() { API.setStatus(API.STATUS.AVAILABLE); API.chatLog("Disponivel"); } function command10() { API.setStatus(API.STATUS.AFK); API.chatLog("AFK"); } function command11() { API.setStatus(API.STATUS.GAMING); API.chatLog("Jogando"); }

function command12(){ if(wooting === true){ _$context.trigger('notify', 'icon-woot', 'Autowoot está ativo!'); }else{ _$context.trigger('notify', 'icon-woot', 'Autowoot está agora ativo!'); wooting = true; woot(); } }

function command13(){ if(wooting === false){ _$context.trigger('notify', 'icon-woot', 'Autowoot está desativado!'); }else{ _$context.trigger('notify', 'icon-woot', 'Autowoot está agora inativo!'); wooting = false; } }

function command14(){ if(joining === true){ _$context.trigger('notify', 'icon-join-waitlist', 'Autojoin já está ativado!'); }else{ _$context.trigger('notify', 'icon-join-waitlist', 'Autojoin está agora ativo!'); joining = true; join(); } }

function command15(){ if(joining === false){ _$context.trigger('notify', 'icon-join-waitlist', 'Autojoin está desativado!'); }else{ _$context.trigger('notify', 'icon-join-waitlist', 'Autojoin está agora inativo!');; joining = false; } }

function command16(){ API.chatLog("Seus pontos: :+1: "+ API.getUser().listenerPoints +" | :musical_note: "+ API.getUser().djPoints +" | :star: "+ API.getUser().curatorPoints); }

function command17(){ var rem = API.getTimeRemaining(); var wlPos = API.getWaitListPosition(); var tempoRes; if( wlPos === -1 ) { tempoRes = (210*(wlPos+1)) + rem; API.chatLog('Desculpe você está tocando, ou não está na lista.'); } else { tempoRes = (210*wlPos)+rem;

if(tempoRes < "5") { } else{ API.chatLog("ETA is " + SecondsToHMS(tempoRes)); } } }

function command18(){ API.off(API.USER_FAN, userfanYou); API.off(API.USER_JOIN, userjoin); API.off(API.DJ_ADVANCE, join); API.off(API.DJ_ADVANCE, woot); API.off(API.CHAT_COMMAND, chatcommand); console.log("IgorPlugWoot Offline."); $("#chat-messages").append("<div class='Gold system'></i><span class='text'>IgorPlugWoot está agora offline!</span></div>"); }

function command19(){ API.chatLog(" - /comandos Manda os comandos do bot"); API.chatLog(" - /askfan ativa e desativa o pedido de fans."); API.chatLog(" - /fanroom dar fan em todos os usuarios da sala."); API.chatLog(" - /unfanroom dar unfan em todos os usuarios da sala."); API.chatLog(" - /fanjoiners ativa e desativa o fan em usuarios que entram na sala."); API.chatLog(" - /fanback ativa e desativa o retorno de fans."); API.chatLog(" - /idle Muda status."); API.chatLog(" - /branco Muda Status."); API.chatLog(" - /work Muda Status."); API.chatLog(" - /disponivel Muda Status."); API.chatLog(" - /afk Muda Status."); API.chatLog(" - /jogando Muda Status."); API.chatLog(" - /woot [on/off] Liga/desliga o autowoot."); API.chatLog(" - /join [on/off] Liga/desliga o autojoin."); API.chatLog(" - /pontos Mostra os seus pontos."); API.chatLog(" - /eta Mostra um tempo aproximado em que você será o DJ."); API.chatLog(" - /off Desliga o bot."); }

API.on(API.CHAT_COMMAND, chatcommand);

function chatcommand(value) { switch(value) { case"/fanback":command5(); break; case"/fanroom":command2(); break; case"/fanjoiners":command4(); break; case"/askfan":command1(); break; case"/unfanroom":command3(); break; case"/branco":command6(); break; case"/idle":command7(); break; case"/work":command8(); break; case"/disponivel":command9(); break; case"/afk":command10(); break; case"/jogando":command11(); break; case"/woot on":command12(); break; case"/woot off":command13(); break; case"/join on":command14(); break; case"/join off":command15(); break; case"/pontos":command16(); break; case"/eta":command17(); break; case"/off":command18(); break; case"/comandos":command19(); break; default:break; } }

setInterval(askingFans, 300000);


All wikipages