|
@@ -1,8 +1,10 @@
|
|
|
-from dataclasses import dataclass
|
|
|
+from dataclasses import dataclass, field
|
|
|
from datetime import datetime
|
|
|
from collections.abc import Callable, Coroutine, Container
|
|
|
from typing import Union, Any, Optional
|
|
|
|
|
|
+from aiosqlite.core import Connection
|
|
|
+
|
|
|
|
|
|
@dataclass
|
|
|
class Attachment:
|
|
@@ -26,7 +28,7 @@ class Message:
|
|
|
class Response:
|
|
|
origin_id: str
|
|
|
channel_id: str
|
|
|
- text: str
|
|
|
+ text: Optional[str]
|
|
|
attachments: list[Attachment]
|
|
|
|
|
|
@staticmethod
|
|
@@ -41,13 +43,12 @@ class Response:
|
|
|
|
|
|
@dataclass
|
|
|
class Context:
|
|
|
- message: Message
|
|
|
config: Callable[[str], Any]
|
|
|
respond: Callable[[], Coroutine[None, None, None]]
|
|
|
- # database: Callable # TODO proper type
|
|
|
+ database: Callable[[], Coroutine[None, None, Connection]]
|
|
|
|
|
|
|
|
|
-CommandType = Callable[[Context], Coroutine[None, None, None]]
|
|
|
+CommandType = Callable[[Message, Context], Coroutine[None, None, None]]
|
|
|
|
|
|
|
|
|
@dataclass
|
|
@@ -55,4 +56,6 @@ class CommandConfiguration:
|
|
|
commands: dict[str, CommandType]
|
|
|
call_and_response: dict[str, str]
|
|
|
aliases: dict[str, str]
|
|
|
- bangs: Container[str] = ("!",)
|
|
|
+ bangs: Container[str] = ("!",)
|
|
|
+ startup: list[Callable[[Context], Coroutine[None, None, None]]] = field(default_factory=list)
|
|
|
+ shutdown: list[Callable[[Context], Coroutine[None, None, None]]] = field(default_factory=list)
|