irclib/src/types/irc.interfaces.ts

173 lines
3.9 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.
* - `wsPingInterval` - `IRCWebSocketConnector` pings the server instead of the server pinging it.
* Here, you can set the ping interval in milliseconds. Defaults to `60000`, 1 minute. This setting
* is ignored if you have specified `skipPings`, in which case, you will need to use a custom pinger
* for the WebSocket.
*/
connOpts?: Record<string, unknown>;
}
export interface IIRCServerData {
/**
* (true host)Name of this server.
*/
name: string;
/**
* Everything this server supports. See IRC documentation for command `005` or `RPL_ISUPPORT` for more info.
*/
serverSupports: Record<string, unknown>;
/**
* Supported channel user modes from the server (e.g. `ohv: @%+`)
*/
supportedModes: Record<string, string>;
/**
* Name of the IRC network. May not be present.
*/
network?: string;
}