Update commands

This commit is contained in:
Pavel Djundik 2016-03-08 15:36:25 +02:00 committed by Maxime Poulin
parent 82e192cd2c
commit 2244dda566
10 changed files with 39 additions and 40 deletions

View File

@ -2,25 +2,24 @@ exports.commands = ["slap", "me"];
exports.input = function(network, chan, cmd, args) {
var irc = network.irc;
var text;
switch (cmd) {
case "slap":
var slap = "slaps " + args[0] + " around a bit with a large trout";
text = "slaps " + args[0] + " around a bit with a large trout";
/* fall through */
case "me":
if (args.length === 0) {
break;
}
var text = slap || args.join(" ");
irc.action(
chan.name,
text
);
irc.emit("message", {
from: irc.user.nick,
to: chan.name,
message: "\u0001ACTION " + text
text = text || args.join(" ");
irc.say(chan.name, "\u0001ACTION " + text + "\u0001");
irc.emit("action", {
nick: irc.user.nick,
target: chan.name,
msg: text
});
break;
}

View File

@ -4,9 +4,9 @@ exports.input = function(network, chan, cmd, args) {
var irc = network.irc;
if (args.length === 2) {
irc.invite(args[0], args[1]); // Channel provided in the command
irc.raw("INVITE", args[0], args[1]); // Channel provided in the command
} else if (args.length === 1 && chan.type === "channel") {
irc.invite(args[0], chan.name); // Current channel
irc.raw("INVITE", args[0], chan.name); // Current channel
}
return true;

View File

@ -3,7 +3,7 @@ exports.commands = ["kick"];
exports.input = function(network, chan, cmd, args) {
if (args.length !== 0) {
var irc = network.irc;
irc.kick(chan.name, args[0]);
irc.raw("KICK", chan.name, args[0]);
}
return true;

View File

@ -21,12 +21,9 @@ exports.input = function(network, chan, cmd, args) {
mode = args[0];
user = args[1];
}
var irc = network.irc;
irc.mode(
chan.name,
mode,
user
);
irc.raw("MODE", chan.name, mode, user);
return true;
};

View File

@ -1,11 +1,20 @@
var _ = require("lodash");
<<<<<<< fbbb3d20d287243d2c3c5525d86801f54f903603
exports.commands = ["msg", "say"];
exports.input = function(network, chan, cmd, args) {
=======
module.exports = function(network, chan, cmd, args) {
if (cmd !== "say" && cmd !== "msg") {
return;
}
>>>>>>> Update commands
if (args.length === 0 || args[0] === "") {
return true;
}
var irc = network.irc;
var target = "";
if (cmd === "msg") {
@ -16,14 +25,16 @@ exports.input = function(network, chan, cmd, args) {
} else {
target = chan.name;
}
var msg = args.join(" ");
irc.send(target, msg);
irc.say(target, msg);
var channel = _.find(network.channels, {name: target});
if (typeof channel !== "undefined") {
irc.emit("message", {
from: irc.user.nick,
to: channel.name,
message: msg
irc.emit("privmsg", {
nick: irc.user.nick,
target: channel.name,
msg: msg
});
}

View File

@ -1,5 +1,4 @@
var _ = require("lodash");
var Msg = require("../../models/msg");
exports.commands = ["notice"];
@ -18,16 +17,10 @@ exports.input = function(network, chan, cmd, args) {
targetChan = chan;
}
var msg = new Msg({
type: Msg.Type.NOTICE,
mode: targetChan.getMode(irc.user.nick),
from: irc.user.nick,
text: message
});
targetChan.messages.push(msg);
this.emit("msg", {
chan: targetChan.id,
msg: msg
irc.emit("notice", {
nick: irc.user.nick,
target: targetChan.name,
msg: message
});
return true;

View File

@ -3,7 +3,7 @@ exports.commands = ["raw", "send", "quote"];
exports.input = function(network, chan, cmd, args) {
if (args.length !== 0) {
var irc = network.irc;
irc.write(args.join(" "));
irc.raw(args);
}
return true;

View File

@ -1,12 +1,11 @@
exports.commands = ["topic"];
exports.input = function(network, chan, cmd, args) {
var msg = "TOPIC";
msg += " " + chan.name;
var msg = chan.name;
msg += args[0] ? (" :" + args.join(" ")) : "";
var irc = network.irc;
irc.write(msg);
irc.raw("TOPIC", msg);
return true;
};

View File

@ -27,6 +27,6 @@ module.exports = function(irc, network) {
});
var random = irc.user.nick + Math.floor(10 + (Math.random() * 89));
irc.raw("NICK", random);
irc.changeNick(random);
});
};

View File

@ -23,7 +23,7 @@ module.exports = function(irc, network) {
});
var msg = new Msg({
type: Msg.Type.PART,
mode: user.mode || "",
mode: (user && user.mode) || "",
text: data.message || "",
hostmask: data.ident + "@" + data.hostname,
from: from