|
@ -1,4 +1,4 @@ |
|
|
from typing import Any, Callable, List, Optional |
|
|
|
|
|
|
|
|
from typing import Any, Callable, List, Optional, Union |
|
|
|
|
|
|
|
|
from paircd.message import Message |
|
|
from paircd.message import Message |
|
|
|
|
|
|
|
@ -15,7 +15,7 @@ def cmd_fn(cmd: str, tmpl: str) -> Callable: |
|
|
return fn |
|
|
return fn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def reply_fn(cmd: int, tmpl: str) -> Callable: |
|
|
|
|
|
|
|
|
def reply_fn(cmd: Union[int, str], tmpl: str) -> Callable: |
|
|
def fn(target: str, *args: List[Any]) -> Message: |
|
|
def fn(target: str, *args: List[Any]) -> Message: |
|
|
msg = f"{target} {tmpl.format(*args)}" |
|
|
msg = f"{target} {tmpl.format(*args)}" |
|
|
return Message(cmd=str(cmd), args=[msg]) |
|
|
return Message(cmd=str(cmd), args=[msg]) |
|
@ -33,6 +33,9 @@ ERR_NOSUCHNICK = reply_fn(401, "{0} :No such nick/channel") |
|
|
ERR_NOSUCHSERVER = reply_fn(402, "{0}: No such server") |
|
|
ERR_NOSUCHSERVER = reply_fn(402, "{0}: No such server") |
|
|
|
|
|
|
|
|
# Command responses |
|
|
# Command responses |
|
|
|
|
|
RPL_WELCOME = reply_fn("001", "Welcome to the Internet Relay Network {0}") |
|
|
|
|
|
RPL_YOURHOST = reply_fn("002", "Your host is {0}, running version {1}") |
|
|
|
|
|
RPL_CREATED = reply_fn("003", "This server was created {0}") |
|
|
RPL_WHOISUSER = reply_fn(311, "{0} {1} {2} * :{3}") |
|
|
RPL_WHOISUSER = reply_fn(311, "{0} {1} {2} * :{3}") |
|
|
RPL_ENDOFWHO = reply_fn(315, "{0} :End of /WHO list") |
|
|
RPL_ENDOFWHO = reply_fn(315, "{0} :End of /WHO list") |
|
|
RPL_ENDOFWHOIS = reply_fn(318, "{0} :End of /WHOIS list") |
|
|
RPL_ENDOFWHOIS = reply_fn(318, "{0} :End of /WHOIS list") |
|
|