irclib/src/bot.ts

31 lines
967 B
TypeScript

import { IRCSocketConnector } from './connector/net.connector';
import { IRCConnection } from './irc';
import { IIRCOptions } from './types/irc.interfaces';
import { formatstr } from './utility/formatstr';
export class IRCBot extends IRCConnection {
constructor(options: IIRCOptions) {
super(options, IRCSocketConnector);
}
/**
* Send a message to the server (`PRIVMSG`)
* @param to Recipient, a channel or a nick
* @param message Message to send
* @param args Additional arguments for message
*/
send(to: string, message: string, ...args: any[]) {
this.write('PRIVMSG %s :%s', to, formatstr(message, ...args));
}
/**
* Send a message to the server (`NOTICE`)
* @param to Recipient, a channel or a nick
* @param message Message to send
* @param args Additional arguments for message
*/
notice(to: string, message: string, ...args: any[]) {
this.write('NOTICE %s :%s', to, formatstr(message, ...args));
}
}