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

raw_message object parsing #383

Open
dbkynd opened this issue Apr 21, 2020 · 2 comments
Open

raw_message object parsing #383

dbkynd opened this issue Apr 21, 2020 · 2 comments

Comments

@dbkynd
Copy link
Contributor

dbkynd commented Apr 21, 2020

Actual behaviour:
Using the raw_message event, the RAW IRC message:
'@badge-info=;badges=broadcaster/1,premium/1;color=#EC5D0F;display-name=DBKynd;emotes=;flags=;id=91544fb6-4e0a-411f-a379-771aad329f35;mod=0;room-id=59351240;subscriber=0;tmi-sent-ts=1587431682109;turbo=0;user-id=59351240;user-type= :dbkynd!dbkynd@dbkynd.tmi.twitch.tv PRIVMSG #dbkynd :dirk is great'
gets parsed as

{
  raw: '@badge-info=;badges=broadcaster/1,premium/1;color=#EC5D0F;display-name=DBKynd;emotes=;flags=;id=91544fb6-4e0a-411f-a379-771aad329f35;mod=0;room-id=59351240;subscriber=0;tmi-sent-ts=1587431682109;turbo=0;user-id=59351240;user-type= :dbkynd!dbkynd@dbkynd.tmi.twitch.tv PRIVMSG #dbkynd :dirk is great',
  tags: {
    'badge-info': true,
    badges: 'broadcaster/1,premium/1',
    color: '#EC5D0F',
    'display-name': 'DBKynd',
    emotes: true,
    flags: true,
    id: '91544fb6-4e0a-411f-a379-771aad329f35',
    mod: '0',
    'room-id': '59351240',
    subscriber: '0',
    'tmi-sent-ts': '1587431682109',
    turbo: '0',
    'user-id': '59351240',
    'user-type': true
  },
  prefix: 'dbkynd!dbkynd@dbkynd.tmi.twitch.tv',
  command: 'PRIVMSG',
  params: [ '#dbkynd', 'dirk is great' ]
}

where emotes=;flags=; turns in to emotes: true, flags: true,
This is both on the message and messageCloned objects (for obvious reasons but thought I'd check both just in case)

This same message captured using the message event parses those fields to null

Expected behaviour:

These fields should be parsed as null similarly to how it is done in the message event

Server configuration

  • Operating system: alpine
  • Node version (if applicable): v12.15.0
  • NPM version (if applicable):
  • tmi.js version: "tmi.js": "^1.5.0",
@AlcaDesign
Copy link
Member

The IRC parser that tmi.js uses (irc-message by Fionn Kelleher (sigkell)) and many other parsers will parse an empty tag as true.

message.tags[pair[0]] = tag.substring(tag.indexOf("=") + 1) || true;

I personally wouldn't choose it to be true but at this point I don't want any backwards incompatible changes. Perhaps an option could be added to change an empty tag to something else like null or an empty string (my preference) with true as the default.

RFC.

@dbkynd
Copy link
Contributor Author

dbkynd commented Apr 21, 2020

Oh hmm... interesting.
Thanks for the prompt response!
Options are always nice, but if that's a standard I can just deal with it.

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

No branches or pull requests

2 participants