hardlounge/src/plugins/inputs/msg.js

31 lines
594 B
JavaScript
Raw Normal View History

2014-09-13 21:29:45 +00:00
var _ = require("lodash");
module.exports = function(network, chan, cmd, args) {
2015-09-30 22:39:57 +00:00
if (cmd !== "say" && cmd !== "msg") {
2014-09-13 21:29:45 +00:00
return;
}
if (args.length === 0 || args[0] === "") {
return;
}
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) {
return;
}
} else {
target = chan.name;
}
2014-12-11 22:34:22 +00:00
var msg = args.join(" ");
irc.send(target, msg);
2014-09-13 21:29:45 +00:00
var channel = _.find(network.channels, {name: target});
if (typeof channel !== "undefined") {
irc.emit("message", {
from: irc.me,
to: channel.name,
2014-12-11 22:34:22 +00:00
message: msg
2014-09-13 21:29:45 +00:00
});
}
};