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.
 

29 lines
874 B

from asyncio import create_task
import logging
from paircd.channel import Channel
from paircd.client import Client
from paircd.log import log_client
from paircd.message import Message
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
channel_name = msg.args[0]
if not channel_name.startswith("#"):
log_client(client, "tried to join invalid channel", level=logging.WARN)
return
channel = server.get_channel_by_name(channel_name)
channel.add_client(client)
client.channels.add(channel_name)
log_client(client, f"joined {channel_name}")
await channel.msg_queue.put(
Message(cmd="JOIN", args=[channel_name], prefix=client.id()).encode()
)