hardlounge/src/plugins/inputs/msg.js

32 lines
611 B
JavaScript
Raw Normal View History

2014-09-13 21:29:45 +00:00
var _ = require("lodash");
module.exports = function(network, chan, cmd, args) {
if (cmd != "say" && cmd != "msg") {
return;
}
if (args.length === 0 || args[0] === "") {
return;
}
var client = this;
var irc = network.irc;
var target = "";
if (cmd == "msg") {
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
});
}
};