Closed Defman21 closed 7 years ago
Note: the regex has been changed to provide compatibility with older versions of IRC (which doesn't have tags supported). I've tested it using Twitches IRC PRIVMSG without tags enabled (which makes Twitch IRC responds without IRC3.2 tags) and it works fine.
Hey, thanks for the PR. I'm currently swamped with other work, but I'll try to take a look at it soon.
The regex + match = @raw.match(/(?:^@([^:]+))?(?::?(\S+) )?(\S+)(.*)/)
will not work the way you expect. I think we need some code logic here and not try to stuff everything into one regex. If there's no first capture, @tags will get the 2nd capture, etc.
If there's no first capture, @tags
will be {}
. (because tags
is nil
and parse_tags(nil)
returns {}
if the argument is nil
)
match = "bye world".match(%r/(hello)? (world)/) # => #<MatchData " world" 1:nil 2:"world">
hello, world = match.captures # => [nil, "world"]
Thanks for the info. I've been bitten by this before, but your method looks safe from this.
Fixes #217 #201