Skip to main content

Nonebot Adapter of Milky Protocol

Project description

nonebot

NoneBot-Adapter-Milky

✨ NoneBot2 Milky 协议适配 / Milky Protocol Adapter for NoneBot2 ✨

协议介绍

Milky 协议

协议端

配置

修改 NoneBot 配置文件 .env 或者 .env.*

Driver

参考 driver 配置项,添加 HTTPClientWebSocketClient 支持。

如:

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
  }
]
'

hostport 为 Milky 协议端设置的监听地址与端口,

access_token 为可选项,具体情况以 Milky 协议端为准。

secure 为可选项,表示是否使用安全连接(即 wss:// 或 https://),默认为 false

MILKY_WEBHOOK

如果你使用的是 Webhook 模式,则需要配置 MILKY_WEBHOOK

MILKY_WEBHOOK='
{
  "host": "localhost",
  "port": "8081",
  "access_token": "xxx",
  "secure": false
}
'

hostport 为 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!"))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_adapter_milky-1.2.0.tar.gz (28.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_adapter_milky-1.2.0-py3-none-any.whl (29.6 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_adapter_milky-1.2.0.tar.gz.

File metadata

  • Download URL: nonebot_adapter_milky-1.2.0.tar.gz
  • Upload date:
  • Size: 28.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.26.7 CPython/3.12.3 Linux/6.17.0-1008-azure

File hashes

Hashes for nonebot_adapter_milky-1.2.0.tar.gz
Algorithm Hash digest
SHA256 f8ea6c91d0e3b8e9560c6ff1e7691a6a590e8ec9cacc9edee109bf174b18e095
MD5 d7ec3fa732eaa08e1b7232d4fb5b56ce
BLAKE2b-256 64d604620e9da3a662e80d7911fcca1ea588a13007b2d6861ea709c826e9a322

See more details on using hashes here.

File details

Details for the file nonebot_adapter_milky-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_adapter_milky-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 393536aaafbb53c15e9675fef38d4e8500526e0f2416119925bdf34d3ad0ef31
MD5 3f5ae7a31d0fb2b6d6fb4f00242ea366
BLAKE2b-256 bfe19c26a6bd00180a04c2a83f74204c283cd56379dc4f0a57813a04c0c22c99

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page