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

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