irc: Add QUIT command
patch 00c6b4424dec6eb5c2f2d2e993084814b673461c
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sat Feb 20 23:52:38 CET 2021
* irc: Add QUIT command
hunk ./irc.py 34
+IRC_QUIT_RX = re.compile(PREFIX + r'QUIT( +:| +|\n)(?P<reason>[^\n]+|)')
hunk ./irc.py 63
+ user.stream = None
+ reason = user.close_reason if user.close_reason else ':Client disconnect'
+ await self.send_users_irc(user, 'QUIT', (reason,))
hunk ./irc.py 109
+ (IRC_QUIT_RX, self.handle_irc_quit, False, False),
hunk ./irc.py 148
- for usr in [x for x in self.users.values() if x.stream]:
- await self.reply_command(usr, user, 'NICK', (nick,))
+ await self.send_users_irc(user, 'NICK', (nick,))
hunk ./irc.py 266
+ async def handle_irc_quit(self, user, reason):
+ self.logger.debug('Handling TOPIC: %s', reason)
+
+ await self.reply_command(user, SRV, 'ERROR', (':Client disconnect',))
+ user.close_reason = ':' + reason
+ user.stream.close()
+
hunk ./irc.py 316
+ async def send_users_irc(self, prfx, command, params):
+ for usr in [x for x in self.users.values() if x.stream]:
+ await self.reply_command(usr, prfx, command, params)
+
hunk ./irc.py 390
+ self.close_reason = ''