sasl and bot stuff
This commit is contained in:
parent
146c7ba900
commit
2b027d57ad
@ -5,6 +5,7 @@ const bot = new IRCBot({
|
||||
host: 'icynet.eu',
|
||||
nick: 'MyTestBot',
|
||||
channels: ['#squeebot'],
|
||||
bot: true,
|
||||
nickserv: {
|
||||
enabled: true,
|
||||
command: 'STATUS',
|
||||
|
26
src/irc.ts
26
src/irc.ts
@ -34,8 +34,17 @@ export class IRCConnectionWrapper
|
||||
public queue: IQueue[] = [];
|
||||
public authenticated = false;
|
||||
public serverData: { [key: string]: any } = {
|
||||
/**
|
||||
* (true host)Name of this server.
|
||||
*/
|
||||
name: '',
|
||||
/**
|
||||
* Supported channel user modes from the server (e.g. `ohv: @%+`)
|
||||
*/
|
||||
supportedModes: {},
|
||||
/**
|
||||
* Everything this server supports. See IRC documentation for command `005` or `RPL_ISUPPORT` for more info.
|
||||
*/
|
||||
serverSupports: {},
|
||||
};
|
||||
|
||||
@ -153,12 +162,20 @@ export class IRCConnectionWrapper
|
||||
this._supportsDone = true;
|
||||
this.emit('supported-modes', this.serverData.supportedModes);
|
||||
this.emit('server-supports', this.serverData.serverSupports);
|
||||
|
||||
if (
|
||||
this.options.bot &&
|
||||
this.serverData.serverSupports.USERMODES &&
|
||||
this.serverData.serverSupports.USERMODES.includes('B')
|
||||
) {
|
||||
this.write('MODE %s +B', this.options.nick);
|
||||
}
|
||||
}
|
||||
|
||||
switch (line.command.toLowerCase()) {
|
||||
case 'cap':
|
||||
if (
|
||||
line.trailing === 'sasl' &&
|
||||
line.trailing.includes('sasl') &&
|
||||
line.arguments?.[1] === 'ACK' &&
|
||||
!this.authenticated
|
||||
) {
|
||||
@ -226,13 +243,14 @@ export class IRCConnectionWrapper
|
||||
this.write('NICK %s', newNick);
|
||||
this.options.nick = newNick;
|
||||
break;
|
||||
case '904': // SASL fail
|
||||
case '902': // ERR_NICKLOCKED
|
||||
case '904': // ERR_SASLFAIL
|
||||
case '905': // ERR_SASLTOOLONG
|
||||
this.emit('error', {
|
||||
error: new Error(line.trailing),
|
||||
fatal: true,
|
||||
});
|
||||
break;
|
||||
case '903': // SASL success
|
||||
case '903': // RPL_SASLSUCCESS
|
||||
this.write('CAP END');
|
||||
break;
|
||||
case 'notice':
|
||||
|
@ -107,4 +107,20 @@ export const RPL_COMMAND = [
|
||||
['258', 'RPL_ADMINLOC2', ':<admin info>'],
|
||||
['259', 'RPL_ADMINEMAIL', ':<admin info>'],
|
||||
['671', 'RPL_WHOISSECURE', '<nick> [<type>] :is using a secure connection'],
|
||||
[
|
||||
'900',
|
||||
'RPL_LOGGEDIN',
|
||||
'<nick> <nick> <ident> <host> <account> :You are now logged in as',
|
||||
],
|
||||
[
|
||||
'901',
|
||||
'RPL_LOGGEDOUT',
|
||||
'<nick> <nick> <ident> <host> <account> :You are now logged out',
|
||||
],
|
||||
['903', 'RPL_SASLSUCCESS', '<nick> :SASL authentication successful'],
|
||||
[
|
||||
'908',
|
||||
'RPL_SASLMECHS',
|
||||
'<nick> <mechanisms> :are available SASL mechanisms',
|
||||
],
|
||||
];
|
||||
|
@ -56,4 +56,17 @@ export const RPL_ERROR = [
|
||||
['491', 'ERR_NOOPERHOST', ':No O-lines for your host'],
|
||||
['501', 'ERR_UMODEUNKNOWNFLAG', ':Unknown MODE flag'],
|
||||
['502', 'ERR_USERSDONTMATCH', ':Cant change mode for other users'],
|
||||
[
|
||||
'902',
|
||||
'ERR_NICKLOCKED',
|
||||
'<nick> <nick> :You must use a nick assigned to you',
|
||||
],
|
||||
['904', 'ERR_SASLFAIL', '<nick> :SASL authentication failed'],
|
||||
['905', 'ERR_SASLTOOLONG', '<nick> :SASL message too long'],
|
||||
['906', 'ERR_SASLABORTED', '<nick> :SASL authentication aborted'],
|
||||
[
|
||||
'907',
|
||||
'ERR_SASLALREADY',
|
||||
'<nick> :You have already authenticated using SASL',
|
||||
],
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user