Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. console.log("FERRAMENTAS ESTÃO OK");
  2.  
  3. const tmi = require('tmi.js');
  4. const NOME_DO_BOT = 'NOME DA SUA CONTA DE BOT'
  5. const NOME_DO_CANAL_QUE_O_BOT_VAI_FICAR = 'NOME DO CANAL'
  6. const O_TOKEN_DO_PASSO_4 = 'TOKEN'
  7.  
  8. const opts = {
  9. identity: {
  10. username: NOME_DO_BOT,
  11. password: O_TOKEN_DO_PASSO_4
  12. },
  13. channels: [ NOME_DO_CANAL_QUE_O_BOT_VAI_FICAR ]
  14. };
  15.  
  16. // Cria um cliente tmi com nossas opções
  17. const client = new tmi.client(opts);
  18.  
  19. //intercepta mensagem do chat
  20. function mensagemChegou(alvo, contexto, mensagem, ehBot) {
  21. if (ehBot) {
  22. return; //se for mensagens do nosso bot ele não faz nada
  23. }
  24.  
  25. const nomeDoComando = mensagem.trim();// remove espaço em branco da mensagem para verificar o comando
  26. // checando o nosso comando
  27. if (nomeDoComando === '!comandoUM') {
  28. console.log(`* Foi Executado o comando ${nomeDoComando}`);
  29. client.say(alvo, `* Você pediu para executar o comando ${nomeDoComando}`);
  30. } else if (nomeDoComando === '!comandoDOIS') {
  31. console.log(`* Foi Executado o comando ${nomeDoComando}`);
  32. client.say(alvo, `* Você pediu para executar o comando ${nomeDoComando}`);
  33. } else {
  34. console.log(`* Não conheço o comando ${commandName}`);
  35. }
  36. }
  37.  
  38. function entrouNoChatDaTwitch(endereco, porta) {
  39. console.log(`* Bot entrou no endereço ${endereco}:${porta}`);
  40. }
  41.  
  42. // Registra nossas funções
  43. client.on('message', mensagemChegou);
  44. client.on('connected', entrouNoChatDaTwitch);
  45. // Connecta na Twitch:
  46. client.connect();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement