Skip to content

Wrong message ID for messages sent from client #529

@Durss

Description

@Durss

Hello :)

There's a very tricky issue with v1.8.5 of tmi.js that might still be an issue with v1.9.0 with this line:

this.userstate[channel] = tags;

(haven't tested with 1.9.0 sorry)

The base of the problem is that when sending a message from TMI.js, we get a on("message") event with a sort of fake message built up by TMI.js as twitch does not send us back the message.
On every USERSTATE event you keep the tags and stuff on a sort of cache so you can populate the next fake data with tags of the previous message. Including its ID.

The ideal would be that TMI would use the client-nonce and wait for the USERSTATE to call the on("message") with proper data on it so the user does not have to worry about this.
As this is not managed yet (on neither version if i'm not mistaken), I managed it on my side for now.

But, as you recycle the tags from the previous USERSTATE event, including the message ID, the new message receives the previous message ID. Because of this, if we try to delete a message based on this ID we actually delete the previous message.

A quick and dirty workaround is to delete the ID before storing it on the local cache:

delete tags.id://Added
this.userstate[channel] = tags;

Thanks for you work !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions