Skip to main content

Nonebot2 Adapter for Weixin Official Accounts Platform

Project description

NoneBot-Adapter-WXMP

✨ 微信公众平台客服 协议适配 ✨

license pypi pypi download python

安装

适配器安装

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秒内响应,超时自动回复空内容。

开源协议

MIT LICENSE

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_wxmp-0.1.8.tar.gz (19.9 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_wxmp-0.1.8-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_adapter_wxmp-0.1.8.tar.gz.

File metadata

  • Download URL: nonebot_adapter_wxmp-0.1.8.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nonebot_adapter_wxmp-0.1.8.tar.gz
Algorithm Hash digest
SHA256 d2eafb8ee42a18bc967cd179d0a0c8aa63104d4effeb2e5ed08b76a379c318dd
MD5 90fdd0147e07ffd687d647aef56c986f
BLAKE2b-256 d8eebc1b18da3418cac036e08a19ea32e91741b9c061c58fc0b47b6ea5bd9b88

See more details on using hashes here.

File details

Details for the file nonebot_adapter_wxmp-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_adapter_wxmp-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 898c88bd22a0100fa6522286a761ac4b6b7b2881a80f132746fb0844796b547d
MD5 b1ab196dcbfeb730714d3444fabcc3bb
BLAKE2b-256 62074578480bc7ee97b507b70f4467ee26c19966f90827dd9e2e42e310350451

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