|
@ -7,6 +7,7 @@ from paircd.message import Message |
|
|
from paircd.server import Server |
|
|
from paircd.server import Server |
|
|
|
|
|
|
|
|
from paircd.handler.join import JoinHandler |
|
|
from paircd.handler.join import JoinHandler |
|
|
|
|
|
from paircd.handler.mode import ModeHandler |
|
|
from paircd.handler.nick import NickHandler |
|
|
from paircd.handler.nick import NickHandler |
|
|
from paircd.handler.privmsg import PrivmsgHandler |
|
|
from paircd.handler.privmsg import PrivmsgHandler |
|
|
from paircd.handler.user import UserHandler |
|
|
from paircd.handler.user import UserHandler |
|
@ -14,6 +15,7 @@ from paircd.handler.who import WhoHandler |
|
|
|
|
|
|
|
|
HANDLER_CLASSES = [ |
|
|
HANDLER_CLASSES = [ |
|
|
JoinHandler, |
|
|
JoinHandler, |
|
|
|
|
|
ModeHandler, |
|
|
NickHandler, |
|
|
NickHandler, |
|
|
PrivmsgHandler, |
|
|
PrivmsgHandler, |
|
|
UserHandler, |
|
|
UserHandler, |
|
@ -33,4 +35,13 @@ async def handle_cmd(server: Server, client: Client, msg: Message) -> None: |
|
|
if msg.cmd not in CMD_HANDLERS: |
|
|
if msg.cmd not in CMD_HANDLERS: |
|
|
client.log(f"used unknown command {msg.cmd}", level=WARN) |
|
|
client.log(f"used unknown command {msg.cmd}", level=WARN) |
|
|
return |
|
|
return |
|
|
await CMD_HANDLERS[msg.cmd].handle(server, client, msg) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handler = CMD_HANDLERS[msg.cmd] |
|
|
|
|
|
if handler.argc is not None and handler.argc != len(msg.args): |
|
|
|
|
|
client.log( |
|
|
|
|
|
"got {len(msg.args)} arguments for {msg.cmd}, expected {handler.argc}", |
|
|
|
|
|
level=WARN, |
|
|
|
|
|
) |
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
await handler.handle(server, client, msg) |