Handle all errors

This commit is contained in:
Mattias Erming 2014-06-13 15:57:11 +02:00
parent 047f8b0302
commit 95596f4039

View File

@ -17,6 +17,7 @@ var sockets = null;
var networks = [];
var events = [
"errors",
"join",
"kick",
"mode",
@ -374,6 +375,16 @@ function event(e, data) {
var channels = this.channels;
switch (e) {
case "errors":
sockets.emit("msg", {
msg: new Msg({
type: "error",
from: "-!-",
text: data.message,
}),
});
break;
case "join":
var chan = _.findWhere(channels, {name: data.channel});
if (typeof chan === "undefined") {
@ -652,14 +663,8 @@ function event(e, data) {
case "whois":
if (!data) {
sockets.emit("msg", {
msg: new Msg({
type: "error",
from: "-!-",
text: "No such nick/channel.",
}),
});
} else {
break;
}
var chan = _.findWhere(channels, {name: data.nickname});
if (typeof chan === "undefined") {
chan = new Chan({
@ -681,7 +686,7 @@ function event(e, data) {
var i = 0;
for (var k in data) {
var key = prefix[k];
if (!key) {
if (!key || data[k].toString() == "") {
continue;
}
var msg = new Msg({
@ -705,7 +710,6 @@ function event(e, data) {
id: chan.id,
msg: msg,
});
}
break;
}
}