hardlounge/src/plugins/inputs/msg.js

43 lines
799 B
JavaScript
Raw Normal View History

2014-09-13 21:29:45 +00:00
var _ = require("lodash");
2016-03-08 13:36:25 +00:00
<<<<<<< fbbb3d20d287243d2c3c5525d86801f54f903603
exports.commands = ["msg", "say"];
exports.input = function(network, chan, cmd, args) {
2016-03-08 13:36:25 +00:00
=======
module.exports = function(network, chan, cmd, args) {
if (cmd !== "say" && cmd !== "msg") {
return;
}
>>>>>>> Update commands
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,
msg: 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
};