Skip to main content

NoneBot adapter for WeChat

Project description

NoneBot-Adapter-Gewechat

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

license version python pypi download

简介

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

安装

pip

pip install nonebot-adapter-gewechat

nb cli

nb adapter install nonebot-adapter-gewechat

配置

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类中已封装接口

示例

from nonebot import on_command, on_message
from nonebot.adapters.gewechat.message import MessageSegment, Message
from nonebot.adapters.gewechat.event import TextMessageEvent, EmojiMessageEvent
from nonebot.adapters.gewechat.bot import Bot
from nonebot.params import CommandArg

revoke = on_command("revoke", priority=5)
@revoke.handle()
async def _(bot: Bot, event: TextMessageEvent, content: Message = CommandArg()):
    text = str(content)
    msgId = text.split(" ")[0]
    newMsgId = text.split(" ")[1]
    createdTime = text.split(" ")[2]
    await revoke.send(MessageSegment.revoke(
        msgId,
        newMsgId,
        createdTime
    ))

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

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_gewechat-0.4.0.tar.gz (23.0 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_gewechat-0.4.0-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_adapter_gewechat-0.4.0.tar.gz.

File metadata

  • Download URL: nonebot_adapter_gewechat-0.4.0.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nonebot_adapter_gewechat-0.4.0.tar.gz
Algorithm Hash digest
SHA256 1ee4333742beb1e74a20aed94baa1180f37f83f17c73aa457359a9d742f2e045
MD5 53b83614200205d7831fd0465350d629
BLAKE2b-256 f69eda9b14a5243ee6df5e9fb3f1880da3f7c36c6afcaa6060ab7edb5f6df707

See more details on using hashes here.

Provenance

The following attestation bundles were made for nonebot_adapter_gewechat-0.4.0.tar.gz:

Publisher: pypi-publish.yml on Shine-Light/nonebot-adapter-gewechat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nonebot_adapter_gewechat-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_adapter_gewechat-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b0308912c9057894de89bf399f05d1ddfd15407327343e4670ae6bce4b6891d
MD5 7431b2dc511ebe2e45e009c9a9836b46
BLAKE2b-256 6503991106878c6ba7cacacad6ec759a69084f6880c799873f980a5c85baa1f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for nonebot_adapter_gewechat-0.4.0-py3-none-any.whl:

Publisher: pypi-publish.yml on Shine-Light/nonebot-adapter-gewechat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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