2014-09-13 21:29:45 +00:00
|
|
|
var _ = require("lodash");
|
|
|
|
|
2016-03-14 04:21:42 +00:00
|
|
|
exports.commands = ["msg", "say"];
|
|
|
|
|
|
|
|
exports.input = function(network, chan, cmd, args) {
|
2014-09-13 21:29:45 +00:00
|
|
|
if (args.length === 0 || args[0] === "") {
|
2016-03-06 09:24:56 +00:00
|
|
|
return true;
|
2014-09-13 21:29:45 +00:00
|
|
|
}
|
2016-03-08 13:36:25 +00:00
|
|
|
|
2014-09-13 21:29:45 +00:00
|
|
|
var irc = network.irc;
|
|
|
|
var target = "";
|
2015-09-30 22:39:57 +00:00
|
|
|
if (cmd === "msg") {
|
2014-09-13 21:29:45 +00:00
|
|
|
target = args.shift();
|
|
|
|
if (args.length === 0) {
|
2016-03-06 09:24:56 +00:00
|
|
|
return true;
|
2014-09-13 21:29:45 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
target = chan.name;
|
|
|
|
}
|
2016-03-08 13:36:25 +00:00
|
|
|
|
2014-12-11 22:34:22 +00:00
|
|
|
var msg = args.join(" ");
|
2016-03-08 13:36:25 +00:00
|
|
|
irc.say(target, msg);
|
|
|
|
|
2014-09-13 21:29:45 +00:00
|
|
|
var channel = _.find(network.channels, {name: target});
|
|
|
|
if (typeof channel !== "undefined") {
|
2016-03-08 13:36:25 +00:00
|
|
|
irc.emit("privmsg", {
|
|
|
|
nick: irc.user.nick,
|
|
|
|
target: channel.name,
|
2016-03-15 09:59:36 +00:00
|
|
|
message: msg
|
2014-09-13 21:29:45 +00:00
|
|
|
});
|
|
|
|
}
|
2016-03-06 09:24:56 +00:00
|
|
|
|
|
|
|
return true;
|
2014-09-13 21:29:45 +00:00
|
|
|
};
|