跳转至

config

HttpClientConfig 🔗

Bases: NamedTuple

HTTP 客户端配置

Source code in src/graia/ariadne/connection/config.py
29
30
31
32
33
class HttpClientConfig(NamedTuple):
    """HTTP 客户端配置"""

    host: str = "http://localhost:8080"
    """mirai-api-http 的 Endpoint"""

host class-attribute instance-attribute 🔗

host: str = 'http://localhost:8080'

mirai-api-http 的 Endpoint

HttpServerConfig 🔗

Bases: NamedTuple

HTTP 服务器配置

Source code in src/graia/ariadne/connection/config.py
36
37
38
39
40
41
42
43
class HttpServerConfig(NamedTuple):
    """HTTP 服务器配置"""

    path: str = "/"
    """服务的 Endpoint """

    headers: Dict[str, str] = {}
    """用于验证的请求头"""

headers class-attribute instance-attribute 🔗

headers: Dict[str, str] = {}

用于验证的请求头

path class-attribute instance-attribute 🔗

path: str = '/'

服务的 Endpoint

WebsocketClientConfig 🔗

Bases: NamedTuple

Websocket 客户端配置

Source code in src/graia/ariadne/connection/config.py
11
12
13
14
15
class WebsocketClientConfig(NamedTuple):
    """Websocket 客户端配置"""

    host: str = "http://localhost:8080"
    """mirai-api-http 的 Endpoint"""

host class-attribute instance-attribute 🔗

host: str = 'http://localhost:8080'

mirai-api-http 的 Endpoint

WebsocketServerConfig 🔗

Bases: NamedTuple

Websocket 服务器配置

Source code in src/graia/ariadne/connection/config.py
18
19
20
21
22
23
24
25
26
class WebsocketServerConfig(NamedTuple):
    """Websocket 服务器配置"""

    path: str = "/"
    """服务的 Endpoint"""
    params: Dict[str, str] = {}
    """用于验证的参数"""
    headers: Dict[str, str] = {}
    """用于验证的请求头"""

headers class-attribute instance-attribute 🔗

headers: Dict[str, str] = {}

用于验证的请求头

params class-attribute instance-attribute 🔗

params: Dict[str, str] = {}

用于验证的参数

path class-attribute instance-attribute 🔗

path: str = '/'

服务的 Endpoint

config 🔗

config(
    account: int, verify_key: str, *configs: Union[Type[U_Config], U_Config]
) -> List[U_Info]

生成 Ariadne 账号配置

Parameters:

  • account (int) –

    账号

  • verify_key (str) –

    mirai-api-http 使用的 VerifyKey

  • *configs (Union[Type[U_Config], U_Config]) –

    配置, 为 HttpClientConfig, WebsocketClientConfig, WebsocketServerConfig, HttpServerConfig 类或实例

Returns:

  • List[U_Info]

    List[U_Info]: 配置列表, 可直接传给 Ariadne

Source code in src/graia/ariadne/connection/config.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
def config(account: int, verify_key: str, *configs: Union[Type[U_Config], U_Config]) -> List[U_Info]:
    """生成 Ariadne 账号配置

    Args:
        account (int): 账号
        verify_key (str): mirai-api-http 使用的 VerifyKey
        *configs (Union[Type[U_Config], U_Config]): 配置, 为 \
            `HttpClientConfig`, `WebsocketClientConfig`, \
            `WebsocketServerConfig`, `HttpServerConfig` 类或实例

    Returns:
        List[U_Info]: 配置列表, 可直接传给 `Ariadne` 类
    """
    assert isinstance(account, int)
    assert isinstance(verify_key, str)
    configs = configs or (HttpClientConfig(), WebsocketClientConfig())
    infos: List[U_Info] = []
    for cfg in configs:
        if isinstance(cfg, type):
            cfg = cfg()
        infos.append(_CFG_INFO_MAP[type(cfg)](account, verify_key, *cfg))
    return infos