Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. var tmi = require('tmi.js');
  2. var readline = require('readline');
  3. var https = require('https');
  4.  
  5. var canais = [];
  6. var client = null;
  7.  
  8.  
  9.  
  10. executar_canais();
  11. conectar();
  12.  
  13. setInterval(function(){
  14.  
  15. canais = [];
  16.  
  17. client.disconnect();
  18.  
  19. executar_canais();
  20. conectar();
  21.  
  22. }, 30 * 60 * 1000);
  23.  
  24. function executar_canais() {
  25. var site = https.get("https://raw.githubusercontent.com/unixcf/twitchCanais-UnixChat/master/canais%2Ctxt", function(pagina) {
  26. var github = readline.createInterface({
  27. input: pagina
  28. });
  29. github.on('line', (line) => {
  30. canais.push(line);
  31. }).on('close', () => {
  32. console.log(canais);
  33. });
  34. });
  35. }
  36.  
  37. function conectar() {
  38. var options = {
  39. options: {
  40. debug: true
  41. },
  42. connection: {
  43. cluster: "aws",
  44. reconnect: true
  45. },
  46. identity: {
  47. username: "usuario",
  48. password: "oauth"
  49. },
  50. channels: canais
  51. };
  52.  
  53. client = new tmi.client(options);
  54. client.connect();
  55.  
  56. client.on("connected", function (address, port) {
  57. console.log("Conectado...");
  58. });
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement