var _ = require("lodash");
var Msg = require("../../models/msg");

module.exports = function(irc, network) {
	var client = this;
	irc.on("notice", function(data) {
		var target = data.to;
		if (target.toLowerCase() == irc.me.toLowerCase()) {
			target = data.from;
		}

		var chan = _.findWhere(network.channels, {name: target});
		if (typeof chan === "undefined") {
			chan = network.channels[0];
		}

		var from = data.from || "";
		if (data.to == "*" || data.from.indexOf(".") !== -1) {
			from = "";
		}
		var msg = new Msg({
			type: Msg.Type.NOTICE,
			from: from,
			text: data.message
		});
		chan.messages.push(msg);
		client.emit("msg", {
			chan: chan.id,
			msg: msg
		});
	});
};

var Msg = require("../../models/msg");

module.exports = function(irc, network) {
	var client = this;
	irc.on("notice", function(data) {
		var lobby = network.channels[0];
		var from = data.from || "";
		if (data.to == "*" || data.from.indexOf(".") !== -1) {
			from = "";
		}
		var msg = new Msg({
			type: Msg.Type.NOTICE,
			from: from,
			text: data.message
		});
		lobby.messages.push(msg);
		client.emit("msg", {
			chan: lobby.id,
			msg: msg
		});
	});
};

--- 
+++ 
@@ -1,19 +1,9 @@
-var _ = require("lodash");
 var Msg = require("../../models/msg");
 
 module.exports = function(irc, network) {
 	var client = this;
 	irc.on("notice", function(data) {
-		var target = data.to;
-		if (target.toLowerCase() == irc.me.toLowerCase()) {
-			target = data.from;
-		}
-
-		var chan = _.findWhere(network.channels, {name: target});
-		if (typeof chan === "undefined") {
-			chan = network.channels[0];
-		}
-
+		var lobby = network.channels[0];
 		var from = data.from || "";
 		if (data.to == "*" || data.from.indexOf(".") !== -1) {
 			from = "";
@@ -23,9 +13,9 @@
 			from: from,
 			text: data.message
 		});
-		chan.messages.push(msg);
+		lobby.messages.push(msg);
 		client.emit("msg", {
-			chan: chan.id,
+			chan: lobby.id,
 			msg: msg
 		});
 	});
Send NOTICE messages to the correct channel

Fixes #177
