This repository has been archived by the owner on Dec 19, 2024. It is now read-only.
forked from GraiaProject/Avilla
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprotocol.py
65 lines (50 loc) · 2.22 KB
/
protocol.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from __future__ import annotations
from satori.config import WebsocketsInfo
from satori.client.network.websocket import WsNetwork
from avilla.core.application import Avilla
from avilla.core.protocol import BaseProtocol, ProtocolConfig
from graia.ryanvk import merge, ref
from .service import SatoriService
class SatoriConfig(ProtocolConfig, WebsocketsInfo):
...
SatoriService.register_config(SatoriConfig, WsNetwork)
def _import_performs():
import avilla.satori.perform.action.message # noqa: F401
import avilla.satori.perform.action.request # noqa: F401
import avilla.satori.perform.context # noqa: F401
import avilla.satori.perform.event.activity
import avilla.satori.perform.event.lifespan
import avilla.satori.perform.event.message
import avilla.satori.perform.event.metadata
import avilla.satori.perform.event.relationship
import avilla.satori.perform.event.request
import avilla.satori.perform.message.deserialize
import avilla.satori.perform.message.serialize # noqa
import avilla.satori.perform.resource_fetch # noqa: F401
class SatoriProtocol(BaseProtocol):
service: SatoriService
_import_performs()
artifacts = {
**merge(
ref("avilla.protocol/satori::action", "message"),
ref("avilla.protocol/satori::action", "request"),
ref("avilla.protocol/satori::context"),
ref("avilla.protocol/satori::resource_fetch"),
ref("avilla.protocol/satori::message", "deserialize"),
ref("avilla.protocol/satori::message", "serialize"),
ref("avilla.protocol/satori::event", "message"),
ref("avilla.protocol/satori::event", "lifespan"),
ref("avilla.protocol/satori::event", "activity"),
ref("avilla.protocol/satori::event", "metadata"),
ref("avilla.protocol/satori::event", "relationship"),
ref("avilla.protocol/satori::event", "request"),
),
}
def __init__(self):
self.service = SatoriService(self)
def ensure(self, avilla: Avilla):
self.avilla = avilla
avilla.launch_manager.add_component(self.service)
def configure(self, config: SatoriConfig):
self.service.apply(config)
return self