2021-12-05 18:33:49 -05:00
|
|
|
import { Channel } from "./Channel.js";
|
|
|
|
import { Client } from "./Client.js";
|
|
|
|
import { MatrixUser } from "./MatrixUser.js";
|
|
|
|
import { IRCMessage } from "./Message.js";
|
|
|
|
import { Server } from "./Server.js";
|
|
|
|
|
|
|
|
export class IRCUser {
|
|
|
|
private clients: Set<Client>
|
|
|
|
private channels: Map<string, Channel>
|
|
|
|
private server: Server
|
|
|
|
private matrixUser: MatrixUser|null
|
|
|
|
public nick: string
|
|
|
|
private ident: string
|
|
|
|
private hostname: string
|
|
|
|
public accountName: string
|
|
|
|
public isAuthed: boolean
|
|
|
|
private txnIdStore: Set<string>
|
|
|
|
constructor(private initialClient: Client, public mxid: string, private accessToken: string) {
|
|
|
|
this.clients = new Set([initialClient]);
|
|
|
|
this.channels = new Map();
|
|
|
|
this.server = initialClient.server;
|
|
|
|
this.matrixUser = null;
|
|
|
|
const mxidSplit = mxid.split(':')
|
|
|
|
this.nick = mxidSplit[0].substr(1);
|
|
|
|
this.ident = this.nick;
|
|
|
|
this.hostname = mxidSplit[1];
|
|
|
|
this.accountName = mxid.slice(1);
|
|
|
|
this.isAuthed = false;
|
|
|
|
this.txnIdStore = new Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
verifyCredentials(accessToken: string): boolean {
|
|
|
|
return accessToken === this.accessToken;
|
|
|
|
}
|
2021-12-05 18:44:21 -05:00
|
|
|
|
|
|
|
getMask(): string {
|
|
|
|
return `${this.nick}!${this.ident}@${this.hostname}`;
|
|
|
|
}
|
2021-12-05 18:33:49 -05:00
|
|
|
}
|