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.

25 lines
756 B

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