Bug 1139233 - Fix IRC /notice command. r=aleth

This commit is contained in:
Patrick Cloke 2015-03-05 13:03:12 -05:00
Родитель d53dd86d30
Коммит 76b00e9fed
2 изменённых файлов: 10 добавлений и 7 удалений

Просмотреть файл

@ -166,11 +166,12 @@ const GenericIRCConversation = {
return messages;
},
sendMsg: function(aMessage) {
sendMsg: function(aMessage, aIsNotice) {
if (!aMessage.length)
return;
if (!this._account.sendMessage("PRIVMSG", [this.name, aMessage])) {
if (!this._account.sendMessage(aIsNotice ? "NOTICE" : "PRIVMSG",
[this.name, aMessage])) {
this.writeMessage(this._account._currentServerName,
_("error.sendMessageFailed"),
{error: true, system: true});

Просмотреть файл

@ -42,7 +42,7 @@ function kickCommand(aMsg, aConv) {
// Send a message directly to a user.
// aMsg is <user> <message>
// aReturnedConv is optional and returns the resulting conversation.
function messageCommand(aMsg, aConv, aReturnedConv) {
function messageCommand(aMsg, aConv, aReturnedConv, aIsNotice = false) {
// Trim leading whitespace.
aMsg = aMsg.trimLeft();
let sep = aMsg.indexOf(" ");
@ -58,7 +58,7 @@ function messageCommand(aMsg, aConv, aReturnedConv) {
}
return privateMessage(aConv, aMsg.slice(sep + 1), aMsg.slice(0, sep),
aReturnedConv);
aReturnedConv, aIsNotice);
}
// aAdd is true to add a mode, false to remove a mode.
@ -92,12 +92,13 @@ function actionCommand(aMsg, aConv) {
// This will open the conversation, and send and display the text.
// aReturnedConv is optional and returns the resulting conversation.
function privateMessage(aConv, aMsg, aNickname, aReturnedConv) {
// aIsNotice is optional and sends a NOTICE instead of a PRIVMSG.
function privateMessage(aConv, aMsg, aNickname, aReturnedConv, aIsNotice) {
if (!aMsg.length)
return false;
let conv = getAccount(aConv).getConversation(aNickname);
conv.sendMsg(aMsg);
conv.sendMsg(aMsg, aIsNotice);
if (aReturnedConv)
aReturnedConv.value = conv;
return true;
@ -340,7 +341,8 @@ var commands = [
{
name: "notice",
get helpString() _("command.notice", "notice"),
run: function(aMsg, aConv) simpleCommand(aConv, "NOTICE", aMsg)
run: function(aMsg, aConv, aReturnedConv)
messageCommand(aMsg, aConv, aReturnedConv, true)
},
{
name: "op",