Node IRC, can't get the metadata in messages

I have a bot made using Node JS and the package Node-IRC [ http://node-irc.readthedocs.io/en/latest/API.html ]

I’m not sure how to capture the meta data in the beginning of the ‘alert’ messages. I’v looked through the lib [ https://github.com/martynsmith/node-irc/blob/master/lib/irc.js ] and cant seem to find where it is being filtered out.

I also seem to have a problem catching all the notices.

bot.addListener(“CLEARCHAT”, function (command){
console.log(command.rawCommand + ‘/’ + command.args + “\n” + JSON.stringify(command, null, 4));

fs.appendFile('host-target.log', JSON.stringify(command, null, 4), function (errs) {
  if (errs) throw errs;
});

});

logs as
{ "prefix": "tmi.twitch.tv", "server": "tmi.twitch.tv", "command": "CLEARCHAT", "rawCommand": "CLEARCHAT", "commandType": "normal", "args": [ "#channel", "user" ] }

I also have listeners setup for USERNOTICE or TARGETHOST, (I know the NOTICE is in the lib) but its never catches these for some reason. I do have one for CAP commands on, this is the return msg
{ "prefix": "tmi.twitch.tv", "server": "tmi.twitch.tv", "command": "CAP", "rawCommand": "CAP", "commandType": "normal", "args": [ "*", "ACK", "twitch.tv/commands" ] }

You can use the tmi.js module to automatically handle parsing every message.

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

let client = new tmi.client({
            options: {
                    debug: true
                },
            connection: {
                    reconnect: true
                },
            identity: {
                    username: 'username',
                    password: 'oauth token'
                },
            channels: [ 'alca' ]
        });

client.on('connected', (addr, port) => {
    console.log(`Connected via ${addr}:${port}`);
});

client.on('clearchat', channel => {
    console.log('Chat cleared in', channel);
});

/* etc. -- https://docs.tmijs.org/v1.1.1/Events.html */

client.connect();

It makes developing for the Twitch Message Interface with Javascript much faster and more simple.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.