kritzware / twitch-bot

🤖 Easily create chat bots for Twitch.tv
https://www.npmjs.com/package/twitch-bot
MIT License
149 stars 36 forks source link

Issuing commands like "/clear" cause code to crash #17

Closed TheIcemanCometh closed 6 years ago

TheIcemanCometh commented 6 years ago

If you issue a command in chat such as /clear, the function formatCLEARCHAT(event) will crash, when it tries to parse out the username and there isn't one.

Possible fix

if (target_username)
  parsed.target_username = target_username.replace(/\r\n/g, '')

Sample data

Event: @room-id=#######;tmi-sent-ts=1516271888978 :tmi.twitch.tv CLEARCHAT #channelname
kritzware commented 6 years ago

Thanks for finding this 👍

I'll take a look into it and fix this issue, unless you'd rather do a pull request?

TheIcemanCometh commented 6 years ago

I can do a pull request, but it won't be for a couple of hours at least. I'm getting ready to head to work.

kritzware commented 6 years ago

No worries, take your time, and thanks for contributing! 😄

bbakersc commented 6 years ago

I tried to create the pull request, but the request gave me a 403 error.