cinchrb / cinch

The IRC Bot Building Framework
http://www.rubydoc.info/gems/cinch
MIT License
1k stars 180 forks source link

Error when connecting to irc.gitter.im #226

Closed Fryguy closed 8 years ago

Fryguy commented 8 years ago

I am writing a chat bot for gitter.im using their IRC bridge (irc.gitter.im). I get the following error when I connect:

[2016/05/19 14:33:54.525] !! /Users/jfrey/.gem/ruby/2.2.4/gems/cinch-2.3.2/lib/cinch/irc.rb:729:in `on_352': undefined method `split' for nil:NilClass (NoMethodError)
[2016/05/19 14:33:54.525] !!    /Users/jfrey/.gem/ruby/2.2.4/gems/cinch-2.3.2/lib/cinch/irc.rb:263:in `parse'
[2016/05/19 14:33:54.526] !!    /Users/jfrey/.gem/ruby/2.2.4/gems/cinch-2.3.2/lib/cinch/irc.rb:151:in `block (2 levels) in start_reading_thread'
[2016/05/19 14:33:54.526] !!    /Users/jfrey/.gem/ruby/2.2.4/gems/cinch-2.3.2/lib/cinch/helpers.rb:123:in `rescue_exception'
[2016/05/19 14:33:54.526] !!    /Users/jfrey/.gem/ruby/2.2.4/gems/cinch-2.3.2/lib/cinch/irc.rb:149:in `block in start_reading_thread'

What I am seeing is that after the /NAMES is sent, the users list is processed. A normal user looks like this:

[2016/05/19 14:33:54.504] >> :irc.gitter.im 352 miq-bot #manageiq/manageiq Fryguy irc.gitter.im irc.gitter.im Fryguy H :0 Jason Frey

However, the failure occurs when processing the "Gitter Bot" user (not my bot...this is Gitter's own internal bot account), whose line looks like this:

[2016/05/19 14:33:54.525] >> :irc.gitter.im 352 miq-bot #manageiq/manageiq gitter :irc.gitter.im irc.gitter.im gitter H :0 Gitter Bot

Notice the : before irc.gitter.im in the middle of the string. This causes the Message#parse_params regex to not properly match. See below for the differences in the values of raw_params after that Regex match.

# with ":irc.gitter.im 352 miq-bot #manageiq/manageiq Fryguy irc.gitter.im irc.gitter.im Fryguy H :0 Jason Frey")
["miq-bot", "#manageiq/manageiq", "Fryguy", "irc.gitter.im", "irc.gitter.im", "Fryguy", "H", "0 Jason Frey"]

# with ":irc.gitter.im 352 miq-bot #manageiq/manageiq gitter :irc.gitter.im irc.gitter.im gitter H :0 Gitter Bot"
["miq-bot", "#manageiq/manageiq", "gitter", "irc.gitter.im irc.gitter.im gitter H :0 Gitter Bot"]

So, I clearly see why it blows up, but I have no idea how to fix it properly. Is this a bug on Gitter's side, or is this a bug in cinch in how it parses the output?

dominikh commented 8 years ago

That we shouldn't crash on bogus input aside, that input there is indeed malformed and a bug in Gitter.

Fryguy commented 8 years ago

OK, thanks, I'll send a bug report over to them.

txdv commented 8 years ago

Can you put a link to the bug report? If they actually have something like that publicly available.

Fryguy commented 8 years ago

This is now fixed via https://github.com/gitterHQ/irc-bridge/pull/54