kiwiirc / irc-framework

🛠️ A better IRC framework for node.js. For bots and full clients.
MIT License
180 stars 62 forks source link

Problem with the handler.network.cap.isEnabled(...) it always returns false even if enabled #338

Closed Madriix closed 1 year ago

Madriix commented 1 year ago

Hi

On https://github.com/kiwiirc/irc-framework/blob/master/src/commands/handlers/channel.js#L218 there is code like handler.network.cap.isEnabled('extended-join') and I found that it returns false all the time from a bnc created in JavaScript with nodejs, whereas yet on this bnc the extended-join is enabled. There is also handler.network.cap.isEnabled('sasl') which returns false, yet it is enabled on the BNC connecting to irc-framework. Where could the problem come from?

The idea I had was to change this:

    JOIN: function(command, handler) {
        let channel;
        let gecos_idx = 1;
        const data = {};

        if (typeof command.params[0] === 'string' && command.params[0] !== '') {
            channel = command.params[0];
        }

        if (handler.network.cap.isEnabled('extended-join')) {
            data.account = command.params[1] === '*' ? false : command.params[1];
            gecos_idx = 2;
        }

        data.nick = command.nick;
        data.ident = command.ident;
        data.hostname = command.hostname;
        data.gecos = command.params[gecos_idx] || '';
        data.channel = channel;
        data.time = command.getServerTime();
        data.tags = command.tags;
        data.batch = command.batch;
        handler.emit('join', data);
    },

by

    JOIN: function(command, handler) {
        let channel;
        let gecos_idx = 1;
        const data = {};

        if (typeof command.params[0] === 'string' && command.params[0] !== '') {
            channel = command.params[0];
        }

//changed
            data.account = command.params[1] === '*' ? false : command.params[1];
            gecos_idx = 2;

        data.nick = command.nick;
        data.ident = command.ident;
        data.hostname = command.hostname;
        data.gecos = command.params[gecos_idx] || '';
        data.channel = channel;
        data.time = command.getServerTime();
        data.tags = command.tags;
        data.batch = command.batch;
        handler.emit('join', data);
    },

It works fine now, but I would have liked the if ( handler.network.cap.isEnabled(...) ) to work properly

I use JBNC to connect to irc-framework: https://github.com/freenode/jbnc/issues/62 having activated the extended-join cap successfully but irc-framework recognizes that it is false with handler.network.cap.isEnabled(...)

ItsOnlyBinary commented 1 year ago

client.requestCap('your/cap');

hope that helps