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

  1. from asyncio import create_task
  2. import logging
  3. from paircd.channel import Channel
  4. from paircd.client import Client
  5. from paircd.message import Message
  6. from paircd.server import Server
  7. async def handle_join(server: Server, client: Client, msg: Message) -> None:
  8. channel_name = msg.args[0]
  9. if not client.registered:
  10. raise RuntimeError("JOIN: not registered")
  11. if not channel_name.startswith("#"):
  12. raise RuntimeError("invalid channel name")
  13. channel = server.get_channel_by_name(channel_name)
  14. channel.add_client(client)
  15. client.channels.add(channel_name)
  16. logging.info(f"{client.hostname} ({client.id()}) joined {channel_name}")
  17. await channel.msg_queue.put(
  18. Message(cmd="JOIN", args=[channel_name], prefix=client.id()).encode()
  19. )