|
@ -7,25 +7,26 @@ from paircd.message import Message |
|
|
from paircd.server import Server |
|
|
from paircd.server import Server |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def handle_join(server: Server, client: Client, msg: Message) -> None: |
|
|
|
|
|
if not client.registered: |
|
|
|
|
|
log_client(client, "join: not registered", level=logging.WARN) |
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
class JoinHandler(CommandHandler): |
|
|
|
|
|
def __init__(self) -> None: |
|
|
|
|
|
super().__init__("JOIN", 1) |
|
|
|
|
|
|
|
|
channel_name = msg.args[0] |
|
|
|
|
|
if not channel_name.startswith("#"): |
|
|
|
|
|
log_client(client, "tried to join invalid channel", level=logging.WARN) |
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
async def handle(self, server: Server, client: Client, msg: Message) -> None: |
|
|
|
|
|
if not client.registered: |
|
|
|
|
|
log_client(client, "join: not registered", level=logging.WARN) |
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
channel = server.get_channel_by_name(channel_name) |
|
|
|
|
|
channel.add_client(client) |
|
|
|
|
|
|
|
|
channel_name = msg.args[0] |
|
|
|
|
|
if not channel_name.startswith("#"): |
|
|
|
|
|
log_client(client, "tried to join invalid channel", level=logging.WARN) |
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
client.channels.add(channel_name) |
|
|
|
|
|
log_client(client, f"joined {channel_name}") |
|
|
|
|
|
|
|
|
channel = server.get_channel_by_name(channel_name) |
|
|
|
|
|
channel.add_client(client) |
|
|
|
|
|
|
|
|
await channel.msg_queue.put( |
|
|
|
|
|
Message(cmd="JOIN", args=[channel_name], prefix=client.id()).encode() |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
client.channels.add(channel_name) |
|
|
|
|
|
log_client(client, f"joined {channel_name}") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JOIN = CommandHandler("JOIN", 1, handle_join) |
|
|
|
|
|
|
|
|
await channel.msg_queue.put( |
|
|
|
|
|
Message(cmd="JOIN", args=[channel_name], prefix=client.id()).encode() |
|
|
|
|
|
) |