diff --git a/ircrobots/matching.py b/ircrobots/matching.py index ea84a87..f19c7a8 100644 --- a/ircrobots/matching.py +++ b/ircrobots/matching.py @@ -3,16 +3,6 @@ from irctokens import Line from .numerics import NUMERIC_NAMES from .interface import IServer, IMatchResponse, IMatchResponseParam -class Numerics(IMatchResponse): - def __init__(self, - numerics: List[str]): - self._numerics = [NUMERIC_NAMES.get(n, n) for n in numerics] - def __repr__(self) -> str: - return f"Numerics({self._numerics!r})" - - def match(self, server: IServer, line: Line): - return line.command in self._numerics - class Response(IMatchResponse): def __init__(self, command: str, @@ -33,6 +23,22 @@ class Response(IMatchResponse): else: return False +class Numeric(Response): + def __init__(self, + name: str, + params: List[IMatchResponseParam]=[]): + super().__init__(NUMERIC_NAMES.get(name, name), params) + +class Numerics(IMatchResponse): + def __init__(self, + numerics: List[str]): + self._numerics = [NUMERIC_NAMES.get(n, n) for n in numerics] + def __repr__(self) -> str: + return f"Numerics({self._numerics!r})" + + def match(self, server: IServer, line: Line): + return line.command in self._numerics + class ResponseOr(IMatchResponse): def __init__(self, *responses: IMatchResponse): self._responses = responses