rage-inducing fix
This commit is contained in:
parent
7d90a97620
commit
fe58bec86f
@ -485,6 +485,9 @@ class Buffer {
|
||||
let mesg = {message: message, sender: sender, type: type, time: time || new Date()}
|
||||
this.messages.push(mesg);
|
||||
|
||||
if(type == "regular")
|
||||
console.log(sender);
|
||||
|
||||
if(this.active)
|
||||
this.appendMessage(mesg);
|
||||
else
|
||||
@ -616,8 +619,12 @@ class InputHandler {
|
||||
|
||||
if(!buf) return;
|
||||
if(inp.trim() == "") return;
|
||||
let listargs = inp.split(' ');
|
||||
|
||||
irc.socket.emit("userinput", {target: buf.name, server: buf.server, message: inp, splitup: inp.split(" ")});
|
||||
if(listargs[0].indexOf('/') == 0)
|
||||
return;
|
||||
|
||||
irc.socket.emit("userinput", {target: buf.name, targetType: buf.type, server: buf.server, message: inp, splitup: inp.split(" ")});
|
||||
this.history.push(inp);
|
||||
clientdom.input.value = "";
|
||||
}
|
||||
@ -723,7 +730,7 @@ class IRCChatWindow {
|
||||
if(buf) {
|
||||
if(autoswitch)
|
||||
this.render(buf);
|
||||
return;
|
||||
return buf;
|
||||
}
|
||||
|
||||
buf = new Buffer(server, name, name, type);
|
||||
@ -731,6 +738,8 @@ class IRCChatWindow {
|
||||
|
||||
if(autoswitch)
|
||||
this.render(buf);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
closeBuffer(buffer) {
|
||||
@ -934,7 +943,10 @@ window.onload = function() {
|
||||
irc.chat.handleQuit(data.server, data.user, data.reason);
|
||||
break;
|
||||
case "message":
|
||||
irc.chat.messageBuffer(data.to, data.server, {message: data.message, type: data.messageType, from: data.user.nickname});
|
||||
if(data.to == irc.serverData[data.server].my_nick)
|
||||
irc.chat.messageBuffer(data.user.nickname, data.server, {message: data.message, type: data.messageType, from: data.user.nickname});
|
||||
else
|
||||
irc.chat.messageBuffer(data.to, data.server, {message: data.message, type: data.messageType, from: data.user.nickname});
|
||||
break;
|
||||
case "channel_nicks":
|
||||
irc.chat.buildNicklist(data.channel, data.server, data.nicks);
|
||||
@ -951,6 +963,7 @@ window.onload = function() {
|
||||
irc.chat.nickChange(data.server, data.nick, data.newNick);
|
||||
break;
|
||||
case "server_message":
|
||||
if(data['error']) data.messageType = "error";
|
||||
if(irc.chat.getBuffersByServer(data.server).length == 0) {
|
||||
if(!irc.serverChatQueue[data.server]) {
|
||||
irc.serverChatQueue[data.server] = [];
|
||||
|
@ -43,6 +43,14 @@ class IRCConnectionHandler {
|
||||
this.conn = connection;
|
||||
}
|
||||
|
||||
handleUserLine(data) {
|
||||
if(data.targetType == "channel" || data.targetType == "message") {
|
||||
this.conn.socket.write('PRIVMSG {0} :{1}\r\n'.format(data.target, data.message));
|
||||
this.conn.emit('pass_to_client', {type: "message", messageType: "privmsg", to: data.target,
|
||||
user: {nickname: this.conn.config.nickname}, message: data.message, server: data.server});
|
||||
}
|
||||
}
|
||||
|
||||
handleServerLine(line) {
|
||||
console.log(line);
|
||||
if(this.conn.queue["supportsmsg"] && line.command != "005") {
|
||||
@ -61,15 +69,17 @@ class IRCConnectionHandler {
|
||||
|
||||
switch(line.command) {
|
||||
case "error":
|
||||
this.conn.emit("error", {type: "irc_error", raw: line.raw});
|
||||
this.conn.emit("connerror", {type: "irc_error", raw: line.raw});
|
||||
break;
|
||||
case "001":
|
||||
this.conn.data.actualServer = line.user.host;
|
||||
this.conn.data.actualServer = line.user.hostname;
|
||||
break
|
||||
case "005":
|
||||
if(!this.conn.queue["supportsmsg"])
|
||||
this.conn.queue["supportsmsg"] = true;
|
||||
|
||||
this.conn.authenticated = true;
|
||||
|
||||
let argv = line.arguments.slice(1);
|
||||
for(let a in argv) {
|
||||
let t = argv[a];
|
||||
@ -219,12 +229,12 @@ class IRCConnection extends EventEmitter {
|
||||
this.socket.setTimeout(3000);
|
||||
|
||||
this.socket.on('error', (data) => {
|
||||
this.emit('error', {type: "sock_error", message: "A socket error occured.", raw: data});
|
||||
this.emit('connerror', {type: "sock_error", message: "A socket error occured.", raw: data});
|
||||
});
|
||||
|
||||
this.socket.on('lookup', (err, address, family, host) => {
|
||||
if(err) {
|
||||
this.emit('error', {type: "resolve_error", message: "Failed to resolve host."});
|
||||
this.emit('connerror', {type: "resolve_error", message: "Failed to resolve host."});
|
||||
} else {
|
||||
this.emit('lookup', {address: address, family: address, host: host});
|
||||
this.config.address = address;
|
||||
@ -249,9 +259,7 @@ class IRCConnection extends EventEmitter {
|
||||
});
|
||||
|
||||
this.socket.on('close', (data) => {
|
||||
if(this.queue['close'])
|
||||
this.emit('closed', {type: "sock_closed_success", raw: data, message: "Connection closed."});
|
||||
else
|
||||
if(!this.queue['close'])
|
||||
this.emit('closed', {type: "sock_closed", raw: data, message: "Connection closed."});
|
||||
|
||||
this.connected = false;
|
||||
|
38
teemant.js
38
teemant.js
@ -38,13 +38,10 @@ io.sockets.on('connection', function (socket) {
|
||||
console.log('clientID: '+socket.id+' connection: ', socket.request.connection._peername);
|
||||
connections[socket.id] = {}
|
||||
|
||||
socket.on('userinput', function(data) {
|
||||
console.log(data);
|
||||
})
|
||||
|
||||
socket.on('disconnect', function() {
|
||||
for (let d in connections[socket.id])
|
||||
connections[socket.id][d].disconnect();
|
||||
if(connections[socket.id][d].connected == true)
|
||||
connections[socket.id][d].disconnect();
|
||||
|
||||
delete connections[socket.id];
|
||||
|
||||
@ -53,6 +50,14 @@ io.sockets.on('connection', function (socket) {
|
||||
|
||||
socket.on('error', (e) => {
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
socket.on('userinput', (data) => {
|
||||
let serv = connections[socket.id][data.server];
|
||||
if(!serv) return;
|
||||
if(serv.authenticated == false) return;
|
||||
|
||||
serv.handler.handleUserLine(data);
|
||||
})
|
||||
|
||||
socket.on('irc_create', function(connectiondata) {
|
||||
@ -65,25 +70,22 @@ io.sockets.on('connection', function (socket) {
|
||||
connections[socket.id][connectiondata.server] = newConnection;
|
||||
|
||||
newConnection.on('authenticated', () => {
|
||||
console.log("******** AUTH DONE **********");
|
||||
console.log("******** AUTH DONE **********");
|
||||
console.log("******** AUTH DONE **********");
|
||||
console.log("******** AUTH DONE **********");
|
||||
console.log("******** AUTH DONE **********");
|
||||
socket.emit('act_client', {type: "event_connect", address: connectiondata.server, network: newConnection.data.network,
|
||||
supportedModes: newConnection.data.supportedModes, nickname: newConnection.config.nickname});
|
||||
});
|
||||
|
||||
newConnection.on('error', (data) => {
|
||||
newConnection.on('connerror', (data) => {
|
||||
let message = "An error occured";
|
||||
let inconnect = false;
|
||||
|
||||
if(!newConnection.authenticated) {
|
||||
console.log(newConnection.authenticated);
|
||||
|
||||
if(newConnection.authenticated == false) {
|
||||
message = "Failed to connect to the server!";
|
||||
inconnect = true;
|
||||
}
|
||||
|
||||
socket.emit('act_client', {type: (inconnect ? 'server_message' : 'connect_message'), message: message, type: 'error', error: true});
|
||||
socket.emit('act_client', {type: (inconnect == true ? 'server_message' : 'connect_message'), message: message, error: true});
|
||||
});
|
||||
|
||||
newConnection.on('pass_to_client', (data) => {
|
||||
@ -94,18 +96,12 @@ io.sockets.on('connection', function (socket) {
|
||||
let message = "Connection closed";
|
||||
let inconnect = false;
|
||||
|
||||
switch(data.type) {
|
||||
case "sock_closed_success":
|
||||
inconnect = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!newConnection.authenticated) {
|
||||
if(newConnection.authenticated == false) {
|
||||
message = "Failed to connect to the server!";
|
||||
inconnect = true;
|
||||
}
|
||||
|
||||
socket.emit('act_client', {type: (inconnect ? 'server_message' : 'connect_message'), message: message, type: 'error', error: true});
|
||||
socket.emit('act_client', {type: (inconnect == true ? 'server_message' : 'connect_message'), message: message, error: true});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user