安装
适配器安装
nb adapter install nonebot-adapter-wxmp
从PyPI 安装
pip install nonebot-adapter-wxmp
或从 GitHub 仓库安装
pip install git+https://github.com/YangRucheng/nonebot-adapter-wxmp.git#egg=nonebot-adapter-wxmp
加载适配器
import nonebot
from nonebot.adapters.wxmp import Adapter as WxmpAdapter
nonebot.init()
driver = nonebot.get_driver()
driver.register_adapter(WxmpAdapter)
配置 .env 文件
配置 Driver
DRIVER=~fastapi+~httpx
配置 Bot
WXMP_BOTS='
[
{
"appid": "", # 小程序 AppID 或 公众号开发者 ID,以 wx 开头
"token": "", # 服务器验证时需要
"secret": "", # 小程序或公众号的密钥
"type": "miniprogram", # 填 miniprogram / official
"callback": "" # 转发到其他 URL
},
{
"appid": "", # 小程序 AppID 或 公众号开发者 ID,以 wx 开头
"token": "", # 服务器验证时需要
"secret": "", # 小程序或公众号的密钥
"type": "official", # 填 miniprogram / official
"approve": false, # 公众号是否微信认证
"callback": ""
}
]
WXMP_OFFICIAL_TIMEOUT=4 # 公众号被动回复超时时间,请根据服务器响应速度填写,必须小于5
WXMP_VERIFY=true # 是否响应签名验证
'
配置消息推送
- URL(服务器地址):
https://example.com/wxmp/revice/<app_id>或https://example.com/wxmp/revice/<app_id>/ - 消息加密方式:明文模式
- 数据格式:推荐 JSON (公众号为 XML)
适配情况
| 小程序(事件推送) | 小程序(发送客服消息) | 公众号(事件推送) | 公众号(发送客服消息) | 公众号(被动回复消息) | |
|---|---|---|---|---|---|
| 文字消息 | ✅ | ✅ | ✅ | ✅ | ✅ |
| 图片消息 | ✅ | ✅ | ✅ | ✅ | ✅ |
| 图文链接 | ❌ | ✅ | ✅ | ❌ | ❌ |
| 小程序卡片 | ✅ | ✅ | ❌ | ❔ | ❌ |
| 语音消息 | ❌ | ❌ | ✅ | ✅ | ✅ |
| 音乐消息 | ❌ | ❌ | ❌ | ||
| 视频消息 | ❌ | ❌ | ✅ | ✅ | ✅ |
| 小视频消息 | ❌ | ❌ | ❌ | ❌ | ❌ |
| 地理位置消息 | ❌ | ❌ | ✅ | ❌ | ❌ |
| 图文消息 | ❌ | ❌ | ❌ | ||
| 菜单消息 | ❌ | ❌ | ❌ | ❌ |
✅已适配 · ❌官方不支持或疑似不支持 · ❔暂未测试或暂未适配
参考文档
微信开发文档
其他补充信息
一些注意事项
- 公众号未微信认证时,不能发送客服消息,只能使用被动回复。
- 被动回复必须在5秒内响应,超时自动回复空内容。
开源协议
Metadata
Release files for nonebot-adapter-wxmp 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nonebot_adapter_wxmp-0.1.8.tar.gz | 19.9 kB | Without provenance | Details for nonebot_adapter_wxmp-0.1.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nonebot_adapter_wxmp-0.1.8-py3-none-any.whl | Python 3 | none | any | Details for nonebot_adapter_wxmp-0.1.8-py3-none-any.whl |
Total release size: 42.3 kB
Release files / nonebot_adapter_wxmp-0.1.8.tar.gz
| Download URL | nonebot_adapter_wxmp-0.1.8.tar.gz |
|---|---|
| Size | 19.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2eafb8ee42a18bc967cd179d0a0c8aa63104d4effeb2e5ed08b76a379c318dd
|
|
BLAKE2b-256 checksum How to use checksums |
d8eebc1b18da3418cac036e08a19ea32e91741b9c061c58fc0b47b6ea5bd9b88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / nonebot_adapter_wxmp-0.1.8-py3-none-any.whl
| Download URL | nonebot_adapter_wxmp-0.1.8-py3-none-any.whl |
|---|---|
| Size | 22.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
898c88bd22a0100fa6522286a761ac4b6b7b2881a80f132746fb0844796b547d
|
|
BLAKE2b-256 checksum How to use checksums |
62074578480bc7ee97b507b70f4467ee26c19966f90827dd9e2e42e310350451
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for nonebot-adapter-wxmp 0.1.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.