Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var DubAPI = require('dubapi');
- new DubAPI({username: 'Putinha-Bot', password: '123456789'}, function(err, bot) {
- if (err) return console.error(err);
- var resp=0;
- var count_fila=0;
- var count_downs = { "downdubs":"0"};
- var teste = 0;
- bla = function(){
- return new Promise(function(fulfill, reject){
- count_downs = bot.getScore();
- fulfill(resultValue);
- });
- };
- console.log('Running DubAPI v' + bot.version);
- function connect() {bot.connect('radioanao');}
- function skip ()
- {
- count_downs = bot.getScore();
- }
- skip = function(){
- return new Promise(function(fulfill, reject){
- count_downs = bot.getScore();
- fulfill(count_downs);
- });
- };
- function skip2()
- {
- count_downs = count_downs.downdubs;
- console.log(count_downs);
- }
- bot.on('connected', function(name) {
- console.log('Connected to ' + name);
- // while(1)
- // {
- // count_downs = bot.getScore();
- // while(count_downs == null);
- // count_downs = count_downs.downdubs;
- // console.log(count_downs);
- // //myPromise.then(console.log(count_downs));
- // //count_downs// = resp.downdubs;
- // //console.log("count_downs");
- // if(count_downs !== 0 && count_downs != null)
- // {
- // resp = bot.getQueue();
- // count_fila = resp.length;
- // console.log(count_downs + " " + count_fila);
- // if(count_fila <= 2 && count_downs >=3)
- // bot.moderateSkip();
- // else if (count_downs >= count_fila/2)
- // bot.moderateSkip();
- // }
- // //wait(5000);
- // }
- });
- function wait(ms){
- var start = new Date().getTime();
- var end = start;
- while(end < start + ms) {
- end = new Date().getTime();
- }
- }
- bot.on('disconnected', function(name) {
- console.log('Disconnected from ' + name);
- setTimeout(connect, 15000);
- });
- bot.on('error', function(err) {
- console.error(err);
- });
- bot.on(bot.events.userJoin, function(name)
- {
- console.log(name);
- //bot.sendChat(resp.length + " pessoas na fila :3");
- });
- bot.on(bot.events.chatMessage, function(data) {
- if(data.message.indexOf("@Putinha-Bot") !== -1)
- {
- if(data.message.indexOf("qual o sentido da vida?") !== -1)
- bot.sendChat("Leitar e ser leitado.");
- else
- {
- bot.sendChat("@" + data.user.username + " Oin :3");
- }
- }
- count_downs = bot.getScore();
- count_downs = count_downs.downdubs;
- if(count_downs !== 0 && count_downs != null)
- {
- resp = bot.getQueue();
- count_fila = resp.length;
- //console.log(count_downs + " " + count_fila);
- if(count_fila <= 2 && count_downs >=3)
- bot.moderateSkip();
- else if (count_downs >= count_fila/2)
- bot.moderateSkip();
- }
- //console.log(data.user.username + ': ' + data.message);
- });
- connect();
- // while(1)
- // {
- // resp = bot.getScore();
- // console.log(resp);
- // //myPromise.then(console.log(count_downs));
- // count_downs = resp.downdubs;
- // console.log(count_downs);
- // if(count_downs !== 0)
- // {
- // resp = bot.getQueue();
- // count_fila = resp.length;
- // //console.log(count_downs + " " + count_fila);
- // if(count_fila <= 2 && count_downs >=3)
- // bot.moderateSkip();
- // else if (count_downs >= count_fila/2)
- // bot.moderateSkip();
- // }
- // }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement