From 06ce48c56530c20a1811174ef9286f052d2aa3a4 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sun, 17 Jan 2016 23:18:43 +0200 Subject: [PATCH] Render user actions separately --- src/plugins/inputs/notice.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/plugins/inputs/notice.js b/src/plugins/inputs/notice.js index b273ae4b..9c1879ce 100644 --- a/src/plugins/inputs/notice.js +++ b/src/plugins/inputs/notice.js @@ -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 + }); };