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.

22 lines
699 B

  1. from paircd.client import Client
  2. from paircd.message import Message
  3. from paircd.server import Server
  4. async def handle_privmsg(server: Server, client: Client, msg: Message) -> None:
  5. recipient = msg.args[0]
  6. raw_msg = msg.args[1]
  7. msg = Message("PRIVMSG", [recipient, f":{raw_msg}"], prefix=client.id()).encode()
  8. for name, other_client in server.clients_by_nick.items():
  9. if name == recipient:
  10. other_client.msg_queue.put_nowait(msg)
  11. return
  12. for name, channel in server.channels_by_name.items():
  13. if name == recipient:
  14. channel.msg_queue.put_nowait(msg)
  15. return
  16. raise RuntimeError(f"Unknown recipient {recipient}")