joshuaskelly / twitch-observer

Turn Twitch chatter into Python events
MIT License
26 stars 6 forks source link

Regex error when parsing USERNOTICE #55

Open PythooonUser opened 6 years ago

PythooonUser commented 6 years ago

Summary

The USERNOTICE event raises an exception under certain circumstances. Maybe it uses a specification not accounted for in the current regex implementation.

The error message/event details reads:

D:\Projects\pythooonchatbot\env\lib\site-packages\twitchobserver\twitchobserver.py:514: RuntimeWarning: Failed to process USERNOTICE message: @badges=subscriber/12,bits/100000;color=#FFCB13;display-name=Colabuechse90;emotes=;id=eb67b448-0a8d-4703-8d6e-aa7d95de3ec3;login=colabuechse90;mod=0;msg-id=subgift;msg-param-months=8;msg-param-recipient-display-name=ChiLLouTLeR;msg-param-recipient-id=141503055;msg-param-recipient-user-name=chilloutler;msg-param-sender-count=16;msg-param-sub-plan-name=Teammitglied;msg-param-sub-plan=1000;room-id=60305470;subscriber=1;system-msg=Colabuechse90\sgifted\sa\sTier\s1\ssub\sto\sChiLLouTLeR!\sThey\shave\sgiven\s16\sGift\sSubs\sin\sthe\schannel!;tmi-sent-ts=1524416686288;turbo=0;user-id=80475276;user-type= :tmi.twitch.tv USERNOTICE #honorius
  warnings.warn(RuntimeWarning('Failed to process {} message: {}'.format(cmd, message)))
ashnasbot commented 5 years ago

I think the PRIVMSG regex is trying to pull a message when there isn't one, seen on the Subscription USERNOTICE.

I've kludged the regex on L72 to: _privmsg_params_re = re.compile('#(\w+)( :)*([\s\S]*)') And then just ignored the extra group on L534: params_match = _privmsg_params_re.match(params)

I'm sure theres a way to drop the unused group but it works at least.

HTH