martynsmith / node-irc

NodeJS IRC client library
GNU General Public License v3.0
1.32k stars 425 forks source link

MODE messages don't appear to work correctly with JustinTV/TwitchTV chat. #123

Closed beauwest closed 10 years ago

beauwest commented 11 years ago

Hey there!

I came across an issue where I'm trying to capture the operators. The event gets fired correctly, but here is what I get:

RAW line: :jtv MODE #crapbot +o beauwest

MESSAGE response: { prefix: 'jtv', nick: 'jtv', user: undefined, host: undefined, command: 'MODE', rawCommand: 'MODE', commandType: 'normal', args: [ '#crapbot', '+o' ] }

The problem is that I have no way of telling which user is modded or unmodded. It may be that JTV IRC sends those messages differently than other IRC servers. One thought I had was passing, along with "message", the raw line so I could do my own parsing if it's different.

Anyway, if you need more info let me know!

beauwest commented 11 years ago

I think I may have found a solution. In irc.js: line 161: var modeArg;

I changed it to: var modeArg = modeArgs[0]; to give it a default.

beauwest commented 11 years ago

Adding o to the next line works as well. if ( mode.match(/^[bklo]$/) ) {

quentinxs commented 11 years ago

You may want to make sure you have the latest and greatest version of node-irc, as the issue may have already been resolved. The code you're referring to has changed, and that particular section is now near line 246.

beauwest commented 11 years ago

I have the latest version available on NPM: 0.3.4.

Looks like that's from about 8 months ago though. I'll pull down a fresh copy from github and link it that way. Thanks!

beauwest commented 11 years ago

FYI, this code issue is still occurring in the latest code. Adding o to the RegEx for matching the mode corrects it.

quentinxs commented 11 years ago

Ok, the problem is node-irc is looking for a message (005) from the IRC server that tells it exactly which modes are supported and the JTV server, being the custom server that it is, just doesn't send it. It does, however, send another message that should include a bunch of supported modes but... well here's a comparison:

Format: 004: [server] [version] [user-modes] [chan-modes] [modes-with-params]

What JTV sends out:

004: tmi.twitch.tv 0.0.1 w n

What a typical IRC server sends out:

004: asimov.freenode.net ircd-seven-1.1.3 DOQRSZaghilopswz CFILMPQbcefgijklmnopqrstvz bkloveqjfI

So all we can verify from the server is that JTV supports "wallops" and "no external messages" which doesn't provide us much to work with to establish a baseline for it.

beauwest commented 11 years ago

That makes sense. I wonder if the best method to allow for custom servers would be to create a configuration option that can be passed to new irc.Client() that would let you specify any supported modes.

quentinxs commented 11 years ago

Of course, it wouldn't hurt to file a bug with @justintv and see if you can't get them to add rpl_isupport (005) to the messages the server sends out upon connection. Because that reply does a lot more than just say the modes the server allows. It tells the client exactly what the server supports (hence, the name).