I am working on a project and I have setup a chatbot that connects to Twitch chat channels.
I am trying to parse chat messages and having some issues related to a KV filter.
An example log looks like this:
@badge-info=<BADGE>/<LEVEL>;badges=<BADGE>/<LEVEL>,<BADGE>/<LEVEL>,<BADGE>/<LEVEL>;client-nonce=<DATA>;color=#<DATA>;display-name=<DATA>;emotes=<DATA>;flags=<DATA>;id=<DATA>;mod=<DATA>;room-id=<DATA>;subscriber=<DATA>;tmi-sent-ts=<DATA>;turbo=<DATA>;user-id=<DATA>;user-type=<DATA> :<DATA>!<DATA>@<DATA>.tmi.twitch.tv <DATA> #<DATA> :<GREEDYDATA>
The problem I am running into is the final KV pair which is:
user-type=<DATA> :
That final key/value pair is hardly populated and what ends up happening is I get randomness parsed into it's place:
- channel_kv.user-type => :cool_beans!cool_beans@cool_beans.tmi.twitch.tv
- channel_kv.user-type => :tmi.twitch.tv
- channel_kv.user-type => :bonj__!bonj__@bonj__.tmi.twitch.tv
A correct parse, where the field does exist, looks like this:
@badge-info=subscriber/37;badges=moderator/1,subscriber/36,partner/1;color=#5B99FF;display-name=StreamElements;emotes=;flags=84-107:;id=ce777d2c-4d39-4125-978f-56a4f793e892;mod=1;room-id=37402112;subscriber=1;tmi-sent-ts=1598219388089;turbo=0;user-id=100135110;user-type=mod :streamelements!streamelements@streamelements.tmi.twitch.tv PRIVMSG #shroud :<GREEDYDATA>
- channel_kv.user-type => mod
I am not sure how to overcome this hurdle and need some guidance.
Thanks all!