Browse Source

Remove redundant argument check

master
Forest Belton 3 years ago
parent
commit
8ca52c6822
1 changed files with 1 additions and 13 deletions
  1. +1
    -13
      paircd/message.py

+ 1
- 13
paircd/message.py View File

@ -3,13 +3,6 @@ from typing import List, Optional
MAX_MESSAGE_SIZE = 512
EXPECTED_ARG_COUNT = {
"NICK": 1,
"USER": 4,
"JOIN": 1,
"PRIVMSG": 2,
}
class ParsingError(Exception):
message: Optional[str]
@ -56,10 +49,5 @@ def parse_message(raw: bytes) -> Message:
raise ParsingError("Message has no command")
cmd = tokens[0].upper()
if cmd in EXPECTED_ARG_COUNT and EXPECTED_ARG_COUNT[cmd] != len(tokens) - 1:
raise ParsingError(
f"{cmd} had {len(tokens)-1} arguments, expected {EXPECTED_ARG_COUNT[cmd]}"
)
tokens[-1] = tokens[-1].strip()
return Message(cmd=tokens[0], args=tokens[1:])
return Message(cmd=cmd, args=tokens[1:])

Loading…
Cancel
Save