///
///
import { EventEmitter } from 'eventemitter3';
import type { PassThrough } from 'stream';
import { Packets } from './addjob';
import { ParamsDL } from './downloader';
import type { FileInfo } from './interfaces/fileinfo';
import type { Job } from './interfaces/job';
export type { Candidate } from './interfaces/candidate';
export type { FileInfo } from './interfaces/fileinfo';
export type { Job, JobMessageEvents } from './interfaces/job';
export type { Packets };
export type GlobalMessageEvents = {
/**
* Event triggered when all jobs are done
* @example
* ```js
* xdccJS.on('can-quit', () => xdccJS.quit())
* ```
*/
'can-quit': () => void;
/**
* Event triggered when .download() has finished downloading all files
* @example
* ```js
* xdccJS.on('ready', () => {
* const job1 = xdccJS.download('bot-A', '20-30')
* const job2 = xdccJS.download('bot-B', 33)
* })
*
* xdccJS.on('done', (job) => {
* if(job.nick === 'bot-A') console.log('done with bot-A')
* if(job.nick === 'bot-B') console.log('done with bot-B')
* })
* ```
*/
done: (job: Job) => void;
/**
* Event triggered while a file is downloading
* @example
* ```js
* xdccJS.on('downloading', (fileInfo, received, percentage, eta) => {
* console.log(`${fileInfo.file} @ ${received} of ${fileInfo.length} [${percentage}%] - ${eta} ms remaining`)
* })
* ```
*/
downloading: (fileInfo: FileInfo, received: number, percentage: number, eta: number) => void;
/**
* Event triggered when a file has been downloaded
* @example
* ```js
* xdccJS.on('downloaded', (fileInfo) => {
* console.log(`${fileInfo.file} saved to ${fileInfo.filePath}`)
* })
* ```
*/
downloaded: (info: FileInfo) => void;
/**
* Event triggered when a download fails
* @example
* ```js
* xdccJS.on('error', (errorMessage, fileInfo) => {
* console.log(`${fileInfo.file} failed to download: ${errorMessage}`)
* })
* ```
*/
error: (error: Error, fileInfo?: FileInfo) => void;
/**
* Event triggered when chunks of data are being received
* @example
* ```js
* xdccJS.on('pipe', (stream, fileInfo) => {
* console.log('sarting download of', fileInfo.file)
* stream.pipe(somewhere)
* })
* ```
*/
pipe: (stream: PassThrough, info: FileInfo) => void;
/**
* Event triggered when a download from the job starts and is ready to be piped
* @example
* ```js
* xdccJS.on('ready', () => {
* console.log('xdccJS is ready to download')
* xdccJS.download('bot', '20-30')
* })
* ```
*/
ready: () => void;
/**
* debug messages
*/
debug: (msg: string) => void;
'irc error': (IrcErrorEventArgs: import('irc-framework').IrcErrorEventArgs) => void;
join: (JoinEventArgs: import('irc-framework').JoinEventArgs) => void;
kick: (QuitEventArgs: import('irc-framework').QuitEventArgs) => void;
message: (MessageEventArgs: import('irc-framework').MessageEventArgs) => void;
mode: (ModeEventArgs: import('irc-framework').ModeEventArgs) => void;
'nick in use': (NickInUseEventArgs: import('irc-framework').NickInUseEventArgs) => void;
'nick invalid': (NickInvalidEventArgs: import('irc-framework').NickInvalidEventArgs) => void;
notice: (MessageEventArgs: import('irc-framework').MessageEventArgs) => void;
part: (QuitEventArgs: import('irc-framework').QuitEventArgs) => void;
quit: (QuitEventArgs: import('irc-framework').QuitEventArgs) => void;
raw: (RawEventArgs: import('irc-framework').RawEventArgs) => void;
'raw socket connected': (event: object) => void;
registered: (RegisteredEventArgs: import('irc-framework').RegisteredEventArgs) => void;
'server options': (ServerOptionsEventArgs: import('irc-framework').ServerOptionsEventArgs) => void;
'socket close': (event: object) => void;
'socket connected': (event: object) => void;
};
/**
* Constructor parameters
*/
export interface Params extends ParamsDL {
encoding?: 'utf8';
}
export default class XDCC extends EventEmitter {
private irc;
/**
* Change config
*/
config: (params: Omit, 'host' | 'port'>) => ParamsDL;
action: (target: string, message: string) => string[];
ban: (channel: string, mask: string) => void;
banlist: (channel: string, cb: (e: Event) => void) => void;
changeNick: (nick: string) => void;
channel: (channel_name: string) => import('irc-framework').IrcChannel;
ctcpRequest: (target: string, type: string, ...params: unknown[]) => void;
ctcpResponse: (target: string, type: string) => void;
invite: (channel: string, nick: string) => void;
join: (channel: string, key?: string | undefined) => void;
mode: (channel: string, mode: string, extra_args?: string[] | undefined) => void;
notice: (target: string, message: string) => string[];
part: (channel: string, message?: string | undefined) => void;
ping: (message?: string | undefined) => void;
raw: (raw_data_line: string) => void;
rawString: {
(...parameters: string[]): string;
(parameters: string[]): string;
};
say: (target: string, message: string) => string[];
sendMessage: (commandName: string, target: string, message: string) => string[];
setTopic: (channel: string, newTopic: string) => void;
unban: (channel: string, mask: string) => void;
who: (target: string, cb: (event: unknown) => void) => void;
whois: (nick: string, cb: (event: unknown) => void) => void;
whowas: (target: string, cb: (event: Event) => unknown) => void;
constructor(params: Partial & {
host: string;
});
get user(): import("irc-framework").IrcUser;
get connected(): boolean;
private get candidates();
private listenNativeEvents;
private listenCustomEvents;
/**
* start jobs and download files
* @param target bot name
* @param packets pack number(s)
* @param ipv6 use ipv6: only needed for passive bots
* @example
* ```js
* xdccJS.on('ready', () => {
* xdccJS.download('XDCC|BLUE', '1-3, 8, 55')
* xdccJS.download('XDCC|RED', [1, 3, 10, 20])
* xdccJS.download('XDCC|YELLOW', 4)
* })
*/
download(target: string, packets: Packets, opts?: Partial<{
ipv6: boolean;
throttle: number;
}>): Promise;
/**
* Quit IRC
*/
quit(): void;
/**
* Search jobs
* @param bot Bot Name
*/
jobs(bot?: string): Promise>;
}