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