diff --git a/chat/locales/en-US/irc.properties b/chat/locales/en-US/irc.properties index e1025fd0db..3407d4697c 100644 --- a/chat/locales/en-US/irc.properties +++ b/chat/locales/en-US/irc.properties @@ -102,6 +102,9 @@ message.parted.reason=: %S message.quit=%1$S has left the room (Quit%2$S). # The paramter is the quit message given by the user. message.quit2=: %S +# %1$S is the nickname of the user that invited us, %2$S is the conversation +# name. +message.inviteReceived=%1$S has invited you to %2$S. # %1$S is the nickname of the invited user, %2$S is the conversation name # they were invited to. message.invited=%1$S was successfully invited to %2$S. diff --git a/chat/protocols/irc/ircBase.jsm b/chat/protocols/irc/ircBase.jsm index 8fd97c277d..d07a05e3dc 100644 --- a/chat/protocols/irc/ircBase.jsm +++ b/chat/protocols/irc/ircBase.jsm @@ -194,9 +194,14 @@ var ircBase = { return true; }, "INVITE": function(aMessage) { - // INVITE - // TODO prompt user to join channel. - return false; + // INVITE + // Auto-accept the invite. + this.joinChat(this.getChatRoomDefaultFieldValues(aMessage.params[1])); + this.getConversation(aMessage.params[1]) + .writeMessage(aMessage.params[0], + _("message.inviteReceived", aMessage.params[0], + aMessage.params[1]), {system: true}); + return true; }, "JOIN": function(aMessage) { // JOIN ( *( "," ) [ *( "," ) ] ) / "0" @@ -794,9 +799,13 @@ var ircBase = { */ "341": function(aMessage) { // RPL_INVITING // - return serverMessage(this, aMessage, - _("message.invited", aMessage.params[1], - aMessage.params[0])); + // Note that servers reply with parameters in the reverse order from the + // above (which is as specified by RFC 2812). + this.getConversation(aMessage.params[2]) + .writeMessage(aMessage.servername, + _("message.invited", aMessage.params[1], + aMessage.params[2]), {system: true}); + return true; }, "342": function(aMessage) { // RPL_SUMMONING // :Summoning user to IRC diff --git a/chat/protocols/irc/ircCommands.jsm b/chat/protocols/irc/ircCommands.jsm index fbc8809a69..79a9957f84 100644 --- a/chat/protocols/irc/ircCommands.jsm +++ b/chat/protocols/irc/ircCommands.jsm @@ -152,7 +152,17 @@ var commands = [ { name: "invite", get helpString() _("command.invite", "invite"), - run: function(aMsg, aConv) simpleCommand(aConv, "INVITE", aMsg) + run: function(aMsg, aConv) { + let params = splitInput(aMsg); + // If no parameters are given. + if (!params[0].length) + return false; + // If only a nick is given, append the current channel name. + if (params.length == 1) + params.push(aConv.name); + + return simpleCommand(aConv, "INVITE", params); + } }, { name: "join",