|
|
@ -5,7 +5,7 @@ from datetime import datetime |
|
|
|
from logging import log, INFO |
|
|
|
from typing import Any, Set |
|
|
|
|
|
|
|
from paircd.reply import QUIT, RPL_CREATED, RPL_MYINFO, RPL_WELCOME, RPL_YOURHOST |
|
|
|
from paircd.reply import RPL_CREATED, RPL_MYINFO, RPL_WELCOME, RPL_YOURHOST |
|
|
|
from paircd.message import Message |
|
|
|
|
|
|
|
|
|
|
@ -48,22 +48,9 @@ class Client: |
|
|
|
try: |
|
|
|
await self.writer.drain() |
|
|
|
except ConnectionResetError: |
|
|
|
await self.quit(server, "Connection reset by peer") |
|
|
|
|
|
|
|
async def quit(self, server: Any, msg: str) -> None: |
|
|
|
if self.closed: |
|
|
|
return |
|
|
|
|
|
|
|
quit_msg = QUIT(msg, prefix=self.id()) |
|
|
|
for client in server.clients_by_nick.values(): |
|
|
|
client.write_message(quit_msg) |
|
|
|
for channel_name in self.channels: |
|
|
|
channel = server.get_channel_by_name(channel_name, create=False) |
|
|
|
if channel is None: |
|
|
|
continue |
|
|
|
channel.remove_client_by_nick(self.nickname) |
|
|
|
server.remove_client_by_name(self.nickname) |
|
|
|
await self.close() |
|
|
|
await server.disconnect_client( |
|
|
|
self.nickname, "Connection reset by peer" |
|
|
|
) |
|
|
|
|
|
|
|
async def close(self) -> None: |
|
|
|
if self.closed: |
|
|
|