Shuo/lib/plugins/irc-events/errors.js

23 lines
504 B
JavaScript
Raw Normal View History

2014-06-29 19:41:02 +00:00
var Msg = require("../../models/msg");
module.exports = function(irc, network) {
var client = this;
irc.on("errors", function(data) {
2014-06-30 01:20:54 +00:00
var lobby = network.channels[0];
2014-06-29 19:41:02 +00:00
var msg = new Msg({
type: Msg.Type.ERROR,
text: data.message,
});
client.emit("msg", {
2014-06-30 01:20:54 +00:00
chan: lobby.id,
2014-06-29 19:41:02 +00:00
msg: msg
});
if (!network.connected) {
if (data.cmd == "ERR_NICKNAMEINUSE") {
2014-07-08 20:50:41 +00:00
var random = irc.me + Math.floor(10 + (Math.random() * 89));
2014-06-29 19:41:02 +00:00
irc.nick(random);
}
}
});
2014-06-26 23:05:47 +00:00
};