Advertisement
Guest User

Untitled

a guest
Dec 30th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. var DubAPI = require('dubapi');
  2.  
  3. new DubAPI({username: 'Putinha-Bot', password: '123456789'}, function(err, bot) {
  4. if (err) return console.error(err);
  5.  
  6. var resp=0;
  7. var count_fila=0;
  8. var count_downs = { "downdubs":"0"};
  9. var teste = 0;
  10.  
  11. bla = function(){
  12. return new Promise(function(fulfill, reject){
  13. count_downs = bot.getScore();
  14. fulfill(resultValue);
  15. });
  16. };
  17.  
  18. console.log('Running DubAPI v' + bot.version);
  19.  
  20. function connect() {bot.connect('radioanao');}
  21.  
  22. function skip ()
  23. {
  24. count_downs = bot.getScore();
  25. }
  26.  
  27. skip = function(){
  28.  
  29. return new Promise(function(fulfill, reject){
  30. count_downs = bot.getScore();
  31. fulfill(count_downs);
  32. });
  33. };
  34.  
  35.  
  36.  
  37. function skip2()
  38. {
  39. count_downs = count_downs.downdubs;
  40. console.log(count_downs);
  41. }
  42.  
  43.  
  44. bot.on('connected', function(name) {
  45. console.log('Connected to ' + name);
  46.  
  47. // while(1)
  48. // {
  49. // count_downs = bot.getScore();
  50. // while(count_downs == null);
  51. // count_downs = count_downs.downdubs;
  52. // console.log(count_downs);
  53. // //myPromise.then(console.log(count_downs));
  54. // //count_downs// = resp.downdubs;
  55. // //console.log("count_downs");
  56. // if(count_downs !== 0 && count_downs != null)
  57. // {
  58. // resp = bot.getQueue();
  59. // count_fila = resp.length;
  60. // console.log(count_downs + " " + count_fila);
  61. // if(count_fila <= 2 && count_downs >=3)
  62. // bot.moderateSkip();
  63. // else if (count_downs >= count_fila/2)
  64. // bot.moderateSkip();
  65. // }
  66. // //wait(5000);
  67. // }
  68.  
  69.  
  70. });
  71.  
  72. function wait(ms){
  73. var start = new Date().getTime();
  74. var end = start;
  75. while(end < start + ms) {
  76. end = new Date().getTime();
  77. }
  78. }
  79.  
  80. bot.on('disconnected', function(name) {
  81. console.log('Disconnected from ' + name);
  82.  
  83. setTimeout(connect, 15000);
  84. });
  85.  
  86. bot.on('error', function(err) {
  87. console.error(err);
  88. });
  89.  
  90. bot.on(bot.events.userJoin, function(name)
  91. {
  92. console.log(name);
  93. //bot.sendChat(resp.length + " pessoas na fila :3");
  94. });
  95.  
  96. bot.on(bot.events.chatMessage, function(data) {
  97. if(data.message.indexOf("@Putinha-Bot") !== -1)
  98. {
  99. if(data.message.indexOf("qual o sentido da vida?") !== -1)
  100. bot.sendChat("Leitar e ser leitado.");
  101. else
  102. {
  103. bot.sendChat("@" + data.user.username + " Oin :3");
  104. }
  105.  
  106. }
  107. count_downs = bot.getScore();
  108. count_downs = count_downs.downdubs;
  109. if(count_downs !== 0 && count_downs != null)
  110. {
  111. resp = bot.getQueue();
  112. count_fila = resp.length;
  113. //console.log(count_downs + " " + count_fila);
  114. if(count_fila <= 2 && count_downs >=3)
  115. bot.moderateSkip();
  116. else if (count_downs >= count_fila/2)
  117. bot.moderateSkip();
  118. }
  119.  
  120. //console.log(data.user.username + ': ' + data.message);
  121. });
  122.  
  123. connect();
  124.  
  125.  
  126.  
  127. // while(1)
  128. // {
  129. // resp = bot.getScore();
  130. // console.log(resp);
  131. // //myPromise.then(console.log(count_downs));
  132. // count_downs = resp.downdubs;
  133. // console.log(count_downs);
  134. // if(count_downs !== 0)
  135. // {
  136. // resp = bot.getQueue();
  137. // count_fila = resp.length;
  138. // //console.log(count_downs + " " + count_fila);
  139. // if(count_fila <= 2 && count_downs >=3)
  140. // bot.moderateSkip();
  141. // else if (count_downs >= count_fila/2)
  142. // bot.moderateSkip();
  143. // }
  144. // }
  145.  
  146. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement