协议介绍
协议端
配置
修改 NoneBot 配置文件 .env 或者 .env.*。
Driver
参考 driver 配置项,添加 HTTPClient 和 WebSocketClient 支持。
如:
DRIVER=~httpx+~websockets
或
DRIVER=~aiohttp
如果你使用的是 Webhook 模式,则可以移除 WebSocketClient 支持,并添加 ASGI 支持。
如:
DRIVER=~httpx+~fastapi
或
DRIVER=~aiohttp+~fastapi
MILKY_CLIENTS
配置连接配置,如:
MILKY_CLIENTS='
[
{
"host": "localhost",
"port": "8080",
"access_token": "xxx",
"secure": false
}
]
'
host 与 port 为 Milky 协议端设置的监听地址与端口,
access_token 为可选项,具体情况以 Milky 协议端为准。
secure 为可选项,表示是否使用安全连接(即 wss:// 或 https://),默认为 false。
MILKY_WEBHOOK
如果你使用的是 Webhook 模式,则需要配置 MILKY_WEBHOOK。
MILKY_WEBHOOK='
{
"host": "localhost",
"port": "8081",
"access_token": "xxx",
"secure": false
}
'
host 与 port 为 Milky 协议端设置的监听地址与端口,
access_token 为可选项,具体情况以 Milky 协议端为准。
secure 为可选项,表示是否使用安全连接(即 wss:// 或 https://),默认为 false。
示例
from nonebot import on_command
from nonebot.adapters.milky import Bot
from nonebot.adapters.milky.event import MessageEvent
from nonebot.adapters.milky.message import MessageSegment
matcher = on_command("test")
@matcher.handle()
async def handle_receive(bot: Bot, event: MessageEvent):
if event.is_private:
await bot.send(event, MessageSegment.text("Hello, world!"))
Metadata
Release files for nonebot-adapter-milky 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nonebot_adapter_milky-1.3.0.tar.gz | 28.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nonebot_adapter_milky-1.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 58.2 kB
Release files / nonebot_adapter_milky-1.3.0.tar.gz
| Download URL | nonebot_adapter_milky-1.3.0.tar.gz |
|---|---|
| Size | 28.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a9b41b56f34633e82ddee31aea1831ee313db0e88f3e412f2105b646e3430b0
|
|
BLAKE2b-256 checksum How to use checksums |
a3536dad74d4ee3768f292979950d6d682667d39d7e671945589ea465dc72e52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.29.0 CPython/3.12.3 Linux/6.17.0-1022-azure
|
Release files / nonebot_adapter_milky-1.3.0-py3-none-any.whl
| Download URL | nonebot_adapter_milky-1.3.0-py3-none-any.whl |
|---|---|
| Size | 29.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b5e028dfd80a8336fb975fce1cf9c5adf0c71514bb1f9c8af9952d81c0937071
|
|
BLAKE2b-256 checksum How to use checksums |
9932485cc8cce3f2ff6d7fa659f27079db9b73a6d13b7bdef0eefa80a39aa857
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.29.0 CPython/3.12.3 Linux/6.17.0-1022-azure
|