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.

21 lines
589 B

  1. import logging
  2. from typing import Any, Dict
  3. from paircd.client import Client
  4. from paircd.message import Message
  5. from paircd.server import Server
  6. CMD_HANDLERS: Dict[str, Any] = {}
  7. CMD_EXPECTED_ARGC: Dict[str, int] = {}
  8. def register_cmd_handler(cmd: str, argc: int, handler) -> None:
  9. CMD_EXPECTED_ARGC[cmd] = argc
  10. CMD_HANDLERS[cmd] = handler
  11. async def handle_cmd(server: Server, client: Client, msg: Message) -> None:
  12. if msg.cmd not in CMD_HANDLERS:
  13. logging.warning(f"Unknown command: {msg.cmd}")
  14. return
  15. await CMD_HANDLERS[msg.cmd](server, client, msg)