Skip to main content

一个 nonebot 的 微信 clawbot 协议适配器

Project description

nonebot

nonebot-adapter-claweixin

✨ weixin clawbot 协议适配 ✨

CodeFactor NoneBot

配置

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

Driver

参考 driver 配置项,添加 HTTPClient 支持

如:

DRIVER=~httpx

配置机器人

可选依赖 nonebot-adapter-claweixin[qrcode] 用于终端中显示二维码 可选依赖 nonebot-adapter-claweixin[login] 用于完整登录流程

环境变量介绍:

环境变量 默认值 作用
CLAWEIXIN_TOKEN [] 微信 bot token 列表。配置后适配器会为每个 token 创建一个 bot 并开始轮询消息。
CLAWEIXIN_LOGIN_QRCODE_IN_INFO false 启动机器人时执行扫码登录流程,并通过日志输出二维码或二维码链接。
CLAWEIXIN_API_ROOT https://ilinkai.weixin.qq.com 微信 iLink API 根地址。只有官方接口地址变化、测试环境、代理网关等场景才需要修改。
CLAWEIXIN_CDN_ROOT https://novac2c.cdn.weixin.qq.com/c2c 微信 CDN 上传/下载根地址,用于图片、文件、视频等媒体上传下载。
CLAWEIXIN_BOT_AGENT nonebot-adapter-claweixin 上报给官方接口的 bot 身份标识,类似 User-Agent,主要用于服务端观测和排查。
CLAWEIXIN_ROUTE_TAG 空字符串 可选路由标签,会作为 SKRouteTag 请求头发送,主要用于测试、灰度或特殊路由。

第一步:登陆

方法一:

配置环境变量:

CLAWEIXIN_LOGIN_QRCODE_IN_INFO=true

这个环境变量会在机器人启动时获取登陆二维码,然后扫描对应二维码(可以通过访问链接/或者安装qrcode 终端扫描)

即可完成登陆和机器人注册,如果需要持久化,可参考第二步

方法二: 有 nb-cli 环境可以使用

nb claweixin-login

无 nb-cli 环境可以直接使用

claweixin-login

此方法会执行完整 CLI 登录流程,支持扫码、已绑定识别、重定向轮询和手机配对码验证 登录成功后会输出 CLAWEIXIN_TOKEN,如需持久化请执行第二步

第二步:可选的持久化 Token

单个机器人

CLAWEIXIN_TOKEN=["xxx"]

多个机器人

CLAWEIXIN_TOKEN=["aaa","bbb"]

相关项目

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_claweixin-0.1.11.tar.gz (26.5 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_claweixin-0.1.11-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_adapter_claweixin-0.1.11.tar.gz.

File metadata

  • Download URL: nonebot_adapter_claweixin-0.1.11.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.7 CPython/3.12.10 Windows/11

File hashes

Hashes for nonebot_adapter_claweixin-0.1.11.tar.gz
Algorithm Hash digest
SHA256 a3801bedd0c27430a2104cb0ffc64b105b4afb509ea236ade4ea4d62bef8d4c0
MD5 1939c9a7278d78e74f151f9e0f56e819
BLAKE2b-256 fd2e9fb0db20e6201546c41d5c085d0d72b2b6d73c97771fc26ada874d9b0bbe

See more details on using hashes here.

File details

Details for the file nonebot_adapter_claweixin-0.1.11-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_adapter_claweixin-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 7dafc998bf4dd853d1d0bfab5ea0114a9bc1d6108be287542c38d2e48e349807
MD5 d51758705ef09643ede24171f9216b6e
BLAKE2b-256 9be9375a50b0373219e2e7e996b4f3c2c533f984dc1945888c323bf05b77be54

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