thelounge/src/plugins/inputs/notice.js

35 lines
696 B
JavaScript
Raw Normal View History

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