Skip to content

NoneBot2 Milky 协议适配器 / Milky Protocol adapter for nonebot2

License

Notifications You must be signed in to change notification settings

nonebot/adapter-milky

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nonebot

NoneBot-Adapter-Milky

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

协议介绍

Milky 协议

协议端

Lagrange,Milky (WIP)

配置

修改 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"
  }
]
'

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

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

MILKY_WEBHOOK

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

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

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

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

示例

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

About

NoneBot2 Milky 协议适配器 / Milky Protocol adapter for nonebot2

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages