remove numerics file

This commit is contained in:
emerson 2022-03-29 16:22:05 -04:00
parent bb2b913b33
commit 19fe53c826
2 changed files with 12 additions and 60 deletions

View file

@ -4,7 +4,6 @@ import { Socket } from 'net';
import { Channel } from './Channel.js';
import { MatrixUser } from './MatrixUser.js';
import { IRCMessage, parseIRCMessage } from './Message.js';
import numerics from './numerics.js';
import { Server } from './Server.js';
export class Client {
@ -151,7 +150,7 @@ export class Client {
else {
const authArray = Buffer.from(message.params[0], 'base64').toString('utf-8').split('\0');
if (!authArray || authArray.length !== 3) {
this.sendMessage(this.server.name, '904', numerics['904']('*'))
this.sendMessage(this.server.name, '904', ['*', "SASL Authentication failed"])
this.closeConnectionWithError('Invalid authentication')
}
if (authArray[2] === this.server.config.SASLPassword) {
@ -359,15 +358,14 @@ export class Client {
singleNamesList.push(singleName);
}
else {
//@ts-ignore
this.sendMessage(this.server.name, "353", numerics["353"](this.user.nick, "=", targetChannel.name, singleNamesList));
this.sendMessage(this.server.name, "353", [this.user.nick, "=", targetChannel.name, `${singleNamesList.join(' ')}`]);
singleNamesList = [];
}
})
if (singleNamesList.length !== 0) {
this.sendMessage(this.server.name, "353", numerics["353"](this.user.nick, "=", targetChannel.name, singleNamesList));
this.sendMessage(this.server.name, "353", [this.user.nick, "=", targetChannel.name, `${singleNamesList.join(' ')}`]);
}
this.sendMessage(this.server.name, "366", numerics["366"](this.user.nick, targetChannel.name));
this.sendMessage(this.server.name, "366", [this.user.nick, targetChannel.name, "End of /NAMES list"]);
}
doNAMES(message: IRCMessage) {
@ -507,10 +505,10 @@ export class Client {
this.closeConnectionWithError("You must use SASL to connect to this server");
return;
}
this.sendMessage(this.server.name, '001', numerics['001'](this.user.nick, this.server.name));
this.sendMessage(this.server.name, '002', numerics['002'](this.user.nick, this.server.name, '0.0.1'));
this.sendMessage(this.server.name, '003', numerics['003'](this.user.nick, 'yesterday'));
this.sendMessage(this.server.name, '004', numerics['004'](this.user.nick, this.server.name, '0.0.1', 'i', 'hnovu'));
this.sendMessage(this.server.name, '001', [this.user.nick, `Welcome to the ${this.server.name} network, ${this.user.nick}`])
this.sendMessage(this.server.name, '002', [this.user.nick, `Your host is ${this.server.name}, running version 0.1.0`]);
this.sendMessage(this.server.name, '003', [this.user.nick, `This server was created yesterday`]);
this.sendMessage(this.server.name, '004', [this.user.nick, this.server.name, '0.1.0', 'i', 'hnouv']);
const iSupportArray = [
'CASEMAPPING=ascii',
'CHANMODES=,,,nu',
@ -521,11 +519,11 @@ export class Client {
if (this.enabledCaps.has('draft/chathistory')) {
iSupportArray.push('CHATHISTORY=50');
}
this.sendMessage(this.server.name, '005', numerics['005'](this.user.nick, iSupportArray));
this.sendMessage(this.server.name, '005', [this.user.nick, ...iSupportArray, 'are supported by this server']);
this.sendMessage(this.server.name, '375', numerics['375'](this.user.nick));
this.sendMessage(this.server.name, '372', numerics['372'](this.user.nick, "It's an MOTD"));
this.sendMessage(this.server.name, '376', numerics['376'](this.user.nick));
this.sendMessage(this.server.name, '375', [this.user.nick, "- Start of MOTD"]);
this.sendMessage(this.server.name, '372', [this.user.nick, "It's an MOTD"]);
this.sendMessage(this.server.name, '376', [this.user.nick, "- End of MOTD"]);
this.sendMessage(this.user.nick, 'MODE', [this.user.nick, '+i']);
this.server.addClient(this);

View file

@ -1,46 +0,0 @@
const numerics = {
"001": (nick: string, serverName: string) => {
return [nick, `Welcome to the ${serverName} network, ${nick}`]
},
"002": (nick: string, serverName: string, version: string) => {
return [nick, `Your host is ${serverName}, running version ${version}`]
},
"003": (nick: string, createdTime: string) => {
return [nick, `This server was created ${createdTime}`]
},
"004": (nick: string, serverName: string, version: string, umodes: string, cmodes: string) => {
return [nick, serverName, version, umodes, cmodes]
},
"005": (nick: string, isupportArray: string[]) => {
return [nick, `${isupportArray.join(' ')} :are supported by this server`]
},
"221": (nick: string, umode: string) => {
return [nick, umode]
},
"324": (nick: string, channel: string, modeString: string) => {
return [nick, channel, modeString];
},
"353": (nick: string, symbol: string, channel: string, nameArray: string[]) => {
return [nick, symbol, channel, `${nameArray.join(' ')}`]
},
"366": (nick: string, channel: string) => {
return [nick, channel, "End of /NAMES list"]
},
"372": (nick: string, motdLine: string) => {
return [nick, motdLine]
},
"375": (nick: string) => {
return [nick, `- Start of MOTD`]
},
"376": (nick: string) => {
return [nick, "End of MOTD"]
},
"433": (nick: string, otherNick: string) => {
return [nick, otherNick, "Nickname is already in use"]
},
"904": (nick: string) => {
return [nick, "SASL authentication failed"]
},
}
export default numerics;