Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Shine-Light/nonebot-adapter-gewechat

Repository files navigation

本项目已不可用!!!

NoneBot-Adapter-Gewechat

✨ NoneBot2 Gewechat Protocol适配器 / Gewechat Protocol Adapter for NoneBot2 ✨

license version python pypi download

简介

本项目为 NoneBot2 提供了一个 Gewechat 适配器。

安装

pip

pip install nonebot-adapter-gewechat
# 如果需要将登录二维码保存为图片,请使用以下命令安装
pip install nonebot-adapter-gewechat[png]

nb cli

nb adapter install nonebot-adapter-gewechat
# 如果需要将登录二维码保存为图片,请使用以下命令安装
nb adapter install nonebot-adapter-gewechat[png]

配置

Driver 配置

需要 HTTP 客户端驱动器ASGI 服务端驱动器
推荐 fastapi+httpx

DRIVER="~fastapi+~httpx"

Gewechat 配置

GEWECHAT_API_URL="http://127.0.0.1:2531/v2/api"
GEWECHAT_DOWNLOAD_API_URL="http://127.0.0.1:2532/download"
GEWECHAT_CALLBACK_URL="http://127.0.0.1:8080/gewechat/callback/collect"
GEWECHAT_CALLBACK_PATH="/callback/collect"
SELF_MSG=false

配置对应 Gewechat 的配置

  • GEWECHAT_API_URL Gewechat API 地址
  • GEWECHAT_DOWNLOAD_API_URL Gewechat 下载 API 地址
  • GEWECHAT_CALLBACK_URL 接收回调地址
  • GEWECHAT_CALLBACK_PATH Gewechat 回调路径
  • SELF_MSG 是否接收自己发送的消息

账号配置

WXID="wxid_xxxxx"
APPID="wx_xxxxxxx"

其中,APPID 留空即为更换设备登录,首次登录请留空

API接口

具体接口可前往GeweChat文档查看, Bot类中已封装接口

Warning

Gewechat目前只支持图片的下载,语音、视频等暂不支持

示例

from nonebot import on_message
from nonebot.adapters.gewechat.message import MessageSegment, Message
from nonebot.adapters.gewechat.event import ImageMessageEvent, EmojiMessageEvent
from nonebot.adapters.gewechat.bot import Bot

revoke = on_message(priority=5)
@revoke.handle()
async def _(bot: Bot, event: ImageMessageEvent):
    await bot.revokeMsg(
        event.FromUserName,
        event.MsgId,
        event.newMsgId,
        event.CreateTime
    )

emoji = on_message(priority=10)
@emoji.handle()
async def _(bot: Bot, event: EmojiMessageEvent):
    await emoji.send(MessageSegment.emoji(
        event.md5,
        event.md5_size
    ))

About

NoneBot2 Gewechat 协议适配器

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages