hardlounge/src/plugins/inputs/msg.js

35 lines
643 B
JavaScript
Raw Normal View History

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);
2016-04-22 16:38:13 +00:00
if (!network.irc.network.cap.isEnabled("echo-message")) {
var channel = network.getChannel(target);
if (typeof channel !== "undefined") {
irc.emit("privmsg", {
nick: irc.user.nick,
target: channel.name,
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
};