Files
qqbotsdk/dist/examples/webhook_bot/main.py
T
snowy-yang 7603db7fd9 feat!: 文档部署改为 docs 分支自动同步,移除 Gitea 工作流与 wrangler 脚本
Gitea 已配置为 GitHub 的镜像,主仓库落在 GitHub:

- 删除 .gitea/(runner 已弃用,六轮实跑不稳定)与
  scripts/deploy_docs.sh(wrangler Direct Upload 路径随之退役,
  CLOUDFLARE_* secrets 不再被 CI 需要)
- deploy-docs.yml 重写:main 的文档文件变更时自动把纯文档组装进
  docs 孤儿分支并强推——Cloudflare Pages 直连 GitHub、生产分支选
  docs、构建命令留空、输出目录 / 即完成零构建接入
- index.html 仓库链接与 README/GUIDE 安装命令补 GitHub 地址;
  CHANGELOG 合并原先两条 CI/部署条目
2026-09-24 21:19:15 +08:00

34 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Webhook 接入最小示例:HTTP 回调收群 @消息并回复。
运行前提:
1. 项目根目录 .env 配好 APPID/APPSECRET,并设 CONNECTER=webhook;
2. intents.toml 订阅 GROUP_AND_C2C_EVENT 分组(仓库默认已开启);
3. 部署在公网 HTTPS 环境(平台仅支持 80/443/8080/8443 端口,
本地调试可内网穿透),回调地址填
https://<你的域名>:<端口><WEBHOOK_PATH>;
4. 开放平台保存回调配置时会先发 op=13 验证请求,SDK 自动完成签名应答。
运行:uv run python examples/webhook_bot/main.py
"""
from qqbotsdk import EventEmitter, main
from qqbotsdk.api import BotApi
from qqbotsdk.payloads import GroupAtMessage
ee = EventEmitter()
@ee.on("GROUP_AT_MESSAGE_CREATE")
async def on_group_message(msg: GroupAtMessage, api: BotApi) -> None:
if not (msg.group_openid and msg.id):
return
await api.post_group_message(
msg.group_openid,
content=f"收到:{msg.content}",
msg_id=msg.id,
)
if __name__ == "__main__":
main(ee)