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) { exports.input = function(network, chan, cmd, args) {
var irc = network.irc; var irc = network.irc;
var text;
switch (cmd) { switch (cmd) {
case "slap": 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 */ /* fall through */
case "me": case "me":
if (args.length === 0) { if (args.length === 0) {
break; break;
} }
var text = slap || args.join(" "); text = text || args.join(" ");
irc.action(
chan.name, irc.say(chan.name, "\u0001ACTION " + text + "\u0001");
text irc.emit("action", {
); nick: irc.user.nick,
irc.emit("message", { target: chan.name,
from: irc.user.nick, msg: text
to: chan.name,
message: "\u0001ACTION " + text
}); });
break; break;
} }

View File

@ -4,9 +4,9 @@ exports.input = function(network, chan, cmd, args) {
var irc = network.irc; var irc = network.irc;
if (args.length === 2) { 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") { } 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; return true;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,6 +27,6 @@ module.exports = function(irc, network) {
}); });
var random = irc.user.nick + Math.floor(10 + (Math.random() * 89)); 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({ var msg = new Msg({
type: Msg.Type.PART, type: Msg.Type.PART,
mode: user.mode || "", mode: (user && user.mode) || "",
text: data.message || "", text: data.message || "",
hostmask: data.ident + "@" + data.hostname, hostmask: data.ident + "@" + data.hostname,
from: from from: from