Browse Source

Use symbolic names for numeric replies where available

master
JustAnotherArchivist 3 years ago
parent
commit
1c41d80125
1 changed files with 6 additions and 6 deletions
  1. +6
    -6
      irclog.py

+ 6
- 6
irclog.py View File

@@ -346,17 +346,17 @@ class IRCClientProtocol(asyncio.Protocol):
self.send(b'CAP END')
elif line.command == 'AUTHENTICATE' and line.params == ['+']:
self.send(b'AUTHENTICATE +')
elif line.command == '903': # SASL auth successful
elif line.command == ircstates.numerics.RPL_SASLSUCCESS:
self.authenticated = True
self.capReqsPending.remove('sasl')
if len(self.capReqsPending) == 0:
self.send(b'CAP END')
elif line.command in ('902', '904', '905', '906', '908'):
elif line.command in ('902', ircstates.numerics.ERR_SASLFAIL, ircstates.numerics.ERR_SASLTOOLONG, ircstates.numerics.ERR_SASLABORTED, ircstates.numerics.RPL_SASLMECHS):
self.logger.error('SASL error, terminating connection')
self.transport.close()

# NICK errors
elif line.command in ('431', '432', '433', '436'):
elif line.command in ('431', ircstates.numerics.ERR_ERRONEUSNICKNAME, ircstates.numerics.ERR_NICKNAMEINUSE, '436'):
self.logger.error(f'Failed to set nickname: {message!r}, terminating connection')
self.transport.close()

@@ -366,7 +366,7 @@ class IRCClientProtocol(asyncio.Protocol):
self.transport.close()

# JOIN errors
elif line.command in ('405', '471', '473', '474', '475'):
elif line.command in (ircstates.numerics.ERR_TOOMANYCHANNELS, ircstates.numerics.ERR_CHANNELISFULL, ircstates.numerics.ERR_INVITEONLYCHAN, ircstates.numerics.ERR_BANNEDFROMCHAN, ircstates.numerics.ERR_BADCHANNELKEY):
self.logger.error(f'Failed to join channel: {message!r}, terminating connection')
self.transport.close()

@@ -375,11 +375,11 @@ class IRCClientProtocol(asyncio.Protocol):
self.logger.error(f'Failed to part channel: {message!r}')

# JOIN/PART errors
elif line.command == '403':
elif line.command == ircstates.numerics.ERR_NOSUCHCHANNEL:
self.logger.error(f'Failed to join or part channel: {message!r}')

# Connection registration reply
elif line.command == '001':
elif line.command == ircstates.numerics.RPL_WELCOME:
self.logger.info('IRC connection registered')
if self.sasl and not self.authenticated:
self.logger.error('IRC connection registered but not authenticated, terminating connection')


Loading…
Cancel
Save