python ircd using asyncio
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

26 lines
789 B

from asyncio import create_task
import logging
from paircd.channel import Channel
from paircd.client import Client
from paircd.message import Message
from paircd.server import Server
async def handle_join(server: Server, client: Client, msg: Message) -> None:
channel_name = msg.args[0]
if not client.registered:
raise RuntimeError("JOIN: not registered")
if not channel_name.startswith("#"):
raise RuntimeError("invalid channel name")
channel = server.get_channel_by_name(channel_name)
channel.add_client(client)
client.channels.add(channel_name)
logging.info(f"{client.hostname} ({client.id()}) joined {channel_name}")
await channel.msg_queue.put(
Message(cmd="JOIN", args=[channel_name], prefix=client.id()).encode()
)