mirror of
https://github.com/thelounge/thelounge
synced 2024-11-11 07:04:18 +00:00
Merge pull request #590 from xPaw/notices
Emit sent notice back to the user
This commit is contained in:
commit
81cc1bb418
1 changed files with 24 additions and 1 deletions
|
@ -1,7 +1,30 @@
|
|||
var _ = require("lodash");
|
||||
var Msg = require("../../models/msg");
|
||||
|
||||
module.exports = function(network, chan, cmd, args) {
|
||||
if (cmd !== "notice" || !args[1]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var message = args.slice(1).join(" ");
|
||||
var irc = network.irc;
|
||||
irc.notice(args[0], args.slice(1).join(" "));
|
||||
irc.notice(args[0], message);
|
||||
|
||||
var targetChan = _.findWhere(network.channels, {name: args[0]});
|
||||
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
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue