satori-python-adapter-milky 0.4.1__tar.gz → 0.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/.mina/adapter_milky.toml +1 -1
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/PKG-INFO +1 -1
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/pyproject.toml +1 -1
- satori_python_adapter_milky-0.4.2/src/satori/adapters/milky/events/base.py +38 -0
- satori_python_adapter_milky-0.4.1/src/satori/adapters/milky/events/base.py +0 -19
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/LICENSE +0 -0
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/README.md +0 -0
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/src/satori/adapters/milky/__init__.py +0 -0
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/src/satori/adapters/milky/api.py +0 -0
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/src/satori/adapters/milky/base.py +0 -0
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/src/satori/adapters/milky/events/__init__.py +0 -0
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/src/satori/adapters/milky/events/group.py +0 -0
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/src/satori/adapters/milky/events/message.py +0 -0
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/src/satori/adapters/milky/events/request.py +0 -0
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/src/satori/adapters/milky/main.py +0 -0
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/src/satori/adapters/milky/message.py +0 -0
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/src/satori/adapters/milky/sse.py +0 -0
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/src/satori/adapters/milky/utils.py +0 -0
- {satori_python_adapter_milky-0.4.1 → satori_python_adapter_milky-0.4.2}/src/satori/adapters/milky/webhook.py +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Awaitable, Callable
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
|
|
6
|
+
from satori import EventType
|
|
7
|
+
from satori.model import Event, Login, LoginStatus, MessageObject
|
|
8
|
+
|
|
9
|
+
from ..utils import MilkyNetwork
|
|
10
|
+
|
|
11
|
+
EventHandler = Callable[[Login, MilkyNetwork, dict], Awaitable[Event | None]]
|
|
12
|
+
|
|
13
|
+
event_handlers: dict[str, EventHandler] = {}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def register_event(event_type: str):
|
|
17
|
+
def decorator(func: EventHandler):
|
|
18
|
+
event_handlers[event_type] = func
|
|
19
|
+
return func
|
|
20
|
+
|
|
21
|
+
return decorator
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@register_event("bot_offline")
|
|
25
|
+
async def bot_offline(login, net, raw):
|
|
26
|
+
return Event(
|
|
27
|
+
EventType.LOGIN_UPDATED,
|
|
28
|
+
datetime.now(),
|
|
29
|
+
login=Login(
|
|
30
|
+
sn=login.sn,
|
|
31
|
+
platform=login.platform,
|
|
32
|
+
adapter=login.adapter,
|
|
33
|
+
status=LoginStatus.DISCONNECT,
|
|
34
|
+
user=login.user,
|
|
35
|
+
features=login.features.copy(),
|
|
36
|
+
),
|
|
37
|
+
message=MessageObject("", raw["data"]["reason"])
|
|
38
|
+
)
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from collections.abc import Awaitable, Callable
|
|
4
|
-
|
|
5
|
-
from satori.model import Event, Login
|
|
6
|
-
|
|
7
|
-
from ..utils import MilkyNetwork
|
|
8
|
-
|
|
9
|
-
EventHandler = Callable[[Login, MilkyNetwork, dict], Awaitable[Event | None]]
|
|
10
|
-
|
|
11
|
-
event_handlers: dict[str, EventHandler] = {}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def register_event(event_type: str):
|
|
15
|
-
def decorator(func: EventHandler):
|
|
16
|
-
event_handlers[event_type] = func
|
|
17
|
-
return func
|
|
18
|
-
|
|
19
|
-
return decorator
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|