2014-06-19 16:55:21 +00:00
|
|
|
var config = require("../../config") || {};
|
2014-06-19 15:28:53 +00:00
|
|
|
var Msg = require("../models/msg");
|
|
|
|
|
|
|
|
module.exports = function(client, sockets) {
|
|
|
|
var network = this;
|
|
|
|
client.on("errors", function(data) {
|
|
|
|
sockets.in("chat").emit("msg", {
|
|
|
|
msg: new Msg({
|
|
|
|
type: "error",
|
|
|
|
from: "-!-",
|
|
|
|
text: data.message,
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
if (!network.connected) {
|
|
|
|
if (data.cmd == "ERR_NICKNAMEINUSE") {
|
|
|
|
var random = config.defaults.nick + Math.floor(10 + (Math.random() * 89));
|
|
|
|
client.nick(random);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|