150 lines
3.1 KiB
TypeScript
150 lines
3.1 KiB
TypeScript
export interface IIRCUser {
|
|
nickname: string;
|
|
username: string;
|
|
hostname: string;
|
|
}
|
|
|
|
export interface IIRCLine {
|
|
/**
|
|
* Sender information
|
|
*/
|
|
user: IIRCUser;
|
|
/**
|
|
* Raw IRC command. You may need to map this to `RPL_ERROR` or `RPL_COMMAND` depending on your needs.
|
|
*/
|
|
command: string;
|
|
/**
|
|
* Arguments of the IRC command. They appear after the command and before the trailing (` :`)
|
|
*/
|
|
arguments: string[];
|
|
/**
|
|
* Trailing of the IRC command. This is the text after ` :` (excluded)
|
|
*/
|
|
trailing: string;
|
|
/**
|
|
* Raw line from the server.
|
|
*/
|
|
raw: string;
|
|
}
|
|
|
|
export interface IUserLine {
|
|
command: string;
|
|
arguments: string[];
|
|
message: string;
|
|
}
|
|
|
|
export interface IQueue<T = any> {
|
|
untracked?: boolean;
|
|
/**
|
|
* Wait for this command from the server.
|
|
*/
|
|
await: string;
|
|
/**
|
|
* Append lines with these commands to buffer.
|
|
*/
|
|
additional?: string[];
|
|
/**
|
|
* From nickname, used for NOTICE and PRIVMSG collectors.
|
|
*/
|
|
from?: string;
|
|
/**
|
|
* Buffer list of additional data.
|
|
*/
|
|
buffer?: T;
|
|
/**
|
|
* Resolve the collector.
|
|
* @param line The line resolving to `await`
|
|
* @param data Additional data in `buffer`, usually only present when using `additional`
|
|
*/
|
|
do(line: IIRCLine, data?: T): void;
|
|
/**
|
|
* Match the lines you're looking for.
|
|
* @param line Server line
|
|
*/
|
|
match?(line: IIRCLine): boolean;
|
|
/**
|
|
* Line matching commands in `additional` will call this function.
|
|
* Use it to populate the `buffer`.
|
|
* @param line Server line
|
|
*/
|
|
digest?(line: IIRCLine): void;
|
|
}
|
|
|
|
export interface INickServOptions {
|
|
enabled: boolean;
|
|
/**
|
|
* NickServ login status command.
|
|
*/
|
|
command: string;
|
|
/**
|
|
* NickServ bot name, defaults to NickServ.
|
|
*/
|
|
nickservBot?: string;
|
|
/**
|
|
* Response command to wait from NickServ, defaults to NOTICE.
|
|
*/
|
|
responseCommand?: string;
|
|
}
|
|
|
|
export interface IIRCOptions {
|
|
/**
|
|
* IRC nickname
|
|
*/
|
|
nick: string;
|
|
/**
|
|
* IRC server hostname
|
|
*/
|
|
host: string;
|
|
/**
|
|
* IRC username
|
|
*/
|
|
username?: string;
|
|
/**
|
|
* Your user's hostname, this will be set automatically on connect.
|
|
* Setting it manually has no effect.
|
|
*/
|
|
hostname?: string;
|
|
/**
|
|
* IRC realname
|
|
*/
|
|
realname?: string;
|
|
/**
|
|
* IRC server port
|
|
*/
|
|
port?: number;
|
|
/**
|
|
* IRC server password.
|
|
* Sometimes also used as nickserv password.
|
|
*/
|
|
password?: string;
|
|
/**
|
|
* Enable SASL authentication.
|
|
*/
|
|
sasl?: boolean;
|
|
/**
|
|
* Enable SSL
|
|
*/
|
|
ssl?: boolean;
|
|
/**
|
|
* Set +B mode on self (servers may not all support this!)
|
|
*/
|
|
bot?: boolean;
|
|
/**
|
|
* List of channels to join on connect
|
|
*/
|
|
channels?: string[];
|
|
/**
|
|
* Additional NickServ options
|
|
*/
|
|
nickserv?: INickServOptions;
|
|
/**
|
|
* Additional options for connections, usually passed right along to socket
|
|
* without additional alterations.
|
|
*
|
|
* Special cases for included connections:
|
|
* - `path` - `IRCWebSocketConnector` will append this to the WebSocket URL.
|
|
* - `skipPings` - Included connectors will not respond to PINGs if set.
|
|
*/
|
|
connOpts?: Record<string, unknown>;
|
|
}
|