Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messages received after leaving a channel. #204

Open
Felwin opened this issue Jan 20, 2017 · 4 comments
Open

Messages received after leaving a channel. #204

Felwin opened this issue Jan 20, 2017 · 4 comments
Milestone

Comments

@Felwin
Copy link

Felwin commented Jan 20, 2017

Actual behaviour:

I detect that the stream is now offline (kraken API streamById return a null stream object), so a part() command is executed, no error occurred, but a minute later I got a new chat message coming from this channel.

Expected behaviour:

After leaving the channel I am expected to not get messages from it anymore.

Error log:

[10:13] info: Executing command: PART #c9sneaky
[10:13] info: Left #c9sneaky
[10:13] info: [#c9sneaky] <kthxxoxo>: (puke)
[10:14] info: [#c9sneaky] <oskomodo>: anyone here?
@stachu540
Copy link

You trying something like this?
https://docs.tmijs.org/v1.1.2/Commands.html#part

@Felwin
Copy link
Author

Felwin commented Jan 22, 2017

Yes, I am using this exact code to leave the channel.
As you can see in the log the command PART is executed, the channel left, there is no other command executed (it would appear in the log) and yet I still got messages after that.
This behavior not always happen, but happened more than one time. Every time it was with big busy channels.

@AlcaDesign
Copy link
Member

I don't know if the module should filter those messages out, but you could do it yourself like this:

let joinedChannels = [];
client.on('join', (channel, username, self) => {
    if(self && !joinedChannels.includes(channel)) {
        joinedChannels.push(channel);
    }
});
client.on('part', (channel, username, self) => {
    if(self && joinedChannels.includes(channel)) {
        joinedChannels.splice(joinedChannels.indexOf(channel), 1);
    }
});
client.on('message', (channel, userstate, message, self) => {
    if(self || !joinedChannels.includes(channel)) {
        return;
    }
    // Code here
});

@Felwin
Copy link
Author

Felwin commented Jan 22, 2017

Yep, that's exactly what I am doing for now. :)
However I don't think this is a normal behavior, it only happen sometimes with big channels, and I am afraid this could cause some performance issue if monitoring a lot of channels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants