|
|
@ -4,12 +4,12 @@ from paircd.message import Message |
|
|
|
|
|
|
|
|
|
|
|
def cmd_fn(cmd: str, tmpl: str) -> Callable: |
|
|
|
def fn(prefix: Optional[str] = None, *args: List[Any]) -> Message: |
|
|
|
def fn(*args: List[Any], prefix: Optional[str] = None) -> Message: |
|
|
|
msg = tmpl.format(*args) |
|
|
|
return ( |
|
|
|
Message(cmd=cmd, args=[msg], prefix=prefix) |
|
|
|
if prefix is not None |
|
|
|
else Message(cmd=str(cmd), args=[msg]) |
|
|
|
else Message(cmd=cmd, args=[msg]) |
|
|
|
) |
|
|
|
|
|
|
|
return fn |
|
|
@ -26,6 +26,7 @@ def reply_fn(cmd: Union[int, str], tmpl: str) -> Callable: |
|
|
|
# Commands |
|
|
|
JOIN = cmd_fn("JOIN", "{0}") |
|
|
|
MODE = cmd_fn("MODE", "{0} {1}") |
|
|
|
PONG = cmd_fn("PONG", ":{0}") |
|
|
|
PRIVMSG = cmd_fn("PRIVMSG", "{0} :{1}") |
|
|
|
|
|
|
|
# Error replies |
|
|
|