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.
 

34 lines
879 B

from logging import WARN
from typing import Dict
from paircd.client import Client
from paircd.command_handler import CommandHandler
from paircd.log import log_client
from paircd.message import Message
from paircd.server import Server
from paircd.handler.join import JOIN
from paircd.handler.nick import NICK
from paircd.handler.privmsg import PRIVMSG
from paircd.handler.user import USER
ALL_HANDLERS = [
JOIN,
NICK,
PRIVMSG,
USER,
]
CMD_HANDLERS: Dict[str, CommandHandler] = {}
def register_cmd_handlers() -> None:
for handler in ALL_HANDLERS:
CMD_HANDLERS[handler.cmd] = handler
async def handle_cmd(server: Server, client: Client, msg: Message) -> None:
if msg.cmd not in CMD_HANDLERS:
log_client(client, f"used unknown command {msg.cmd}", level=WARN)
return
await CMD_HANDLERS[msg.cmd].handler(server, client, msg)