An elegant OneBot 11 protocol framework for Python, inspired by Graia Ariadne.
Project description
Anchor 是基于 Graia Ariadne 设计重构的 OneBot 11 协议框架,保留了 Ariadne 优雅的 MessageChain 消息链设计和 graia 生态的核心组件(graia-broadcast、launart、creart)。
特性
- 扩展支持 — 表情回应、Markdown、群精华等
- 保留 MessageChain 设计 — 丰富的消息段类型与链式查询 API
- graia 生态兼容 — 支持
graia-broadcast、graia-saya
安装
pip install graiax-anchor
推荐使用 uv:
uv add graiax-anchor
快速开始
from graia.broadcast import Broadcast
from graiax.anchor import Anchor, OneBotConfig
from graiax.anchor.event.message import GroupMessageEvent
broadcast = Broadcast()
app = Anchor(
broadcast=broadcast,
config=OneBotConfig(
ws_url="ws://localhost:3001",
access_token="your_token",
),
)
@broadcast.receiver(GroupMessageEvent)
async def on_group_message(event: GroupMessageEvent):
chain = event.message_chain
if chain.startswith("/hello"):
await app.send_group_msg(event.group_id, "Hello, World!")
app.launch_blocking()
更多示例请参考 demo.md。
项目结构
graiax.anchor
├── app.py # Anchor 主应用类, 80+ API 方法
├── log.py # 日志系统 (LogConfig)
├── connection/ # HTTP / WebSocket 客户端与配置
├── event/ # OneBot 11 事件模型 (消息/通知/请求/元事件)
├── message/
│ ├── segment.py # 消息段类型 (Text, Image, At, Reply, Forward, ...)
│ ├── chain.py # MessageChain 消息链
│ └── parser/ # 消息解析器 (DetectPrefix, MatchRegex, ...)
├── model/ # 数据模型 (Friend, Group, Member, ...)
├── dispatcher.py # graia-broadcast Dispatcher
├── service.py # Launart 服务
└── util/ # 工具 (发送策略, 验证器, Saya 集成)
协议
本项目以 GNU AGPL-3.0 作为开源协议。
致谢
- Graia Ariadne — 框架设计灵感来源
- NapCat — OneBot 11 协议实现
- graia-broadcast — 事件分发系统
- launart — 服务生命周期管理
如果认为本项目有帮助, 欢迎点一个 Star.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
graiax_anchor-0.1.1.tar.gz
(138.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file graiax_anchor-0.1.1.tar.gz.
File metadata
- Download URL: graiax_anchor-0.1.1.tar.gz
- Upload date:
- Size: 138.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
552a57bb5ca8a9b5c889152b26b1bf1e033029a86ca3f4ff7e7e039e7ffebb6f
|
|
| MD5 |
128ac8313beac9365878e2fcd137e8a0
|
|
| BLAKE2b-256 |
425d0e8ae2a95604e81e2e930be6156d19aa3d90c8255a19f0903a75d0f5183c
|
File details
Details for the file graiax_anchor-0.1.1-py3-none-any.whl.
File metadata
- Download URL: graiax_anchor-0.1.1-py3-none-any.whl
- Upload date:
- Size: 65.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1daea8674494d251379de1312c823b5e690c0b17b8f94edcf20695c0d007adc5
|
|
| MD5 |
9e5e43635538def02247ecef39b7aacf
|
|
| BLAKE2b-256 |
70d011fd9a9d8c6060b140c89bda973134efc207662a2e814fb4ec3240d731f9
|