tmijs / tmi.js

💬 Javascript library for the Twitch Messaging Interface. (Twitch.tv)
https://tmijs.com
MIT License
1.55k stars 215 forks source link

Twitch IRC Capability notice #336

Open loicngr opened 5 years ago

loicngr commented 5 years ago

I'am trying to get a event when a moderator unban a user in the chat, i send a resquest for twitch.tv/tags but i didn't receive any messages when user was ban or unban...

it is my code :

const WebSocket = require('ws');

const ws = new WebSocket('wss://irc-ws.chat.twitch.tv:443');

ws.onopen = function(event) {
  console.log('INFO: Socket Opened'); 
  ws.send('CAP REQ :twitch.tv/commands');
  ws.send('CAP REQ :twitch.tv/membership');
  ws.send('CAP REQ :twitch.tv/tags');
  ws.send('PASS oauth:...');
  ws.send('NICK zaekof_');
  ws.send('JOIN #zaekof_');
  ws.send('USER #zaekof_');
};
ws.onerror = function(error) {
  console.log('ERR: ', error);
};
ws.onclose = function() {
  console.log('INFO: Socket Closed');
}; 
ws.onmessage = function(event) {
  console.log('RECV: ', event.data);
};

When i'am connected on irc chat, i receive a follows messages :

RECV:  :tmi.twitch.tv CAP * ACK :twitch.tv/commands
RECV:  :tmi.twitch.tv CAP * ACK :twitch.tv/membership
RECV:  :tmi.twitch.tv CAP * ACK :twitch.tv/tags

RECV:  :tmi.twitch.tv 001 zaekof_ :Welcome, GLHF!
:tmi.twitch.tv 002 zaekof_ :Your host is tmi.twitch.tv
:tmi.twitch.tv 003 zaekof_ :This server is rather new
:tmi.twitch.tv 004 zaekof_ :-
:tmi.twitch.tv 375 zaekof_ :-
:tmi.twitch.tv 372 zaekof_ :You are in a maze of twisty passages, all alike.:tmi.twitch.tv 376 zaekof_ :>

After that, as it didn't work, i'm trying to get my events with tmi.js script, like that :

const tmi = require("tmi.js");

let options = {
  options: {
    debug: true,
    clientId: '....'
  },
  connection: {
    server: 'irc-ws.chat.twitch.tv',
    reconnect: true,
    secure: true
  },
  identity: {
    username: "....",
    password: "oauth:...."
  },
  channels: [ "#z..." ],
};

let client = new tmi.client(options);

client.on("notice", (channel, msgid, message) => {
  console.log(msgid, message);
});

client.connect();

I didn't have any return when i use /unban in chat, i'm confused, I must have missed something.. It is a right way to do what i want ?

Thanks 💯