|
@@ -28,8 +28,8 @@ class Message:
|
|
|
class Response:
|
|
|
origin_id: str
|
|
|
channel_id: str
|
|
|
- text: Optional[str]
|
|
|
- attachments: list[Attachment]
|
|
|
+ text: Optional[str] = None
|
|
|
+ attachments: Optional[list[Attachment]] = None
|
|
|
|
|
|
@staticmethod
|
|
|
def from_message(msg: Message, text: Optional[str] = None, attachments: list[Attachment] = None) -> "Response":
|
|
@@ -54,9 +54,28 @@ StartupShutdownType = Callable[[Context], Coroutine[None, None, None]]
|
|
|
|
|
|
@dataclass
|
|
|
class CommandConfiguration:
|
|
|
- commands: dict[str, CommandType]
|
|
|
- call_and_response: dict[str, str]
|
|
|
- aliases: dict[str, str]
|
|
|
+ commands: dict[str, CommandType] = field(default_factory=dict)
|
|
|
+ call_and_response: dict[str, str] = field(default_factory=dict)
|
|
|
+ aliases: dict[str, str] = field(default_factory=dict)
|
|
|
bangs: Container[str] = ("!",)
|
|
|
startup: list[StartupShutdownType] = field(default_factory=list)
|
|
|
- shutdown: list[StartupShutdownType] = field(default_factory=list)
|
|
|
+ shutdown: list[StartupShutdownType] = field(default_factory=list)
|
|
|
+
|
|
|
+ def extend(self, other: "CommandConfiguration") -> "CommandConfiguration":
|
|
|
+ return CommandConfiguration(
|
|
|
+ commands={
|
|
|
+ **self.commands,
|
|
|
+ **other.commands,
|
|
|
+ },
|
|
|
+ call_and_response={
|
|
|
+ **self.call_and_response,
|
|
|
+ **other.call_and_response,
|
|
|
+ },
|
|
|
+ aliases={
|
|
|
+ **self.aliases,
|
|
|
+ **other.aliases,
|
|
|
+ },
|
|
|
+ bangs=(*self.bangs, *other.bangs),
|
|
|
+ startup=[*self.startup, *other.startup],
|
|
|
+ shutdown=[*self.shutdown, *other.shutdown],
|
|
|
+ )
|