2016-01-17 21:18:43 +00:00
|
|
|
var _ = require("lodash");
|
|
|
|
var Msg = require("../../models/msg");
|
|
|
|
|
2016-03-14 04:21:42 +00:00
|
|
|
exports.commands = ["notice"];
|
|
|
|
|
|
|
|
exports.input = function(network, chan, cmd, args) {
|
|
|
|
if (!args[1]) {
|
2014-09-13 21:29:45 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-01-17 21:18:43 +00:00
|
|
|
|
|
|
|
var message = args.slice(1).join(" ");
|
2014-09-13 21:29:45 +00:00
|
|
|
var irc = network.irc;
|
2016-01-17 21:18:43 +00:00
|
|
|
irc.notice(args[0], message);
|
|
|
|
|
2016-02-14 17:09:51 +00:00
|
|
|
var targetChan = _.find(network.channels, {name: args[0]});
|
2016-01-17 21:18:43 +00:00
|
|
|
if (typeof targetChan === "undefined") {
|
|
|
|
message = "{to " + args[0] + "} " + message;
|
|
|
|
targetChan = chan;
|
|
|
|
}
|
|
|
|
|
|
|
|
var msg = new Msg({
|
|
|
|
type: Msg.Type.NOTICE,
|
|
|
|
mode: targetChan.getMode(irc.me),
|
|
|
|
from: irc.me,
|
|
|
|
text: message
|
|
|
|
});
|
|
|
|
targetChan.messages.push(msg);
|
|
|
|
this.emit("msg", {
|
|
|
|
chan: targetChan.id,
|
|
|
|
msg: msg
|
|
|
|
});
|
2016-03-06 09:24:56 +00:00
|
|
|
|
|
|
|
return true;
|
2014-09-13 21:29:45 +00:00
|
|
|
};
|