Skip to main content

English | 简体中文 | 繁體中文 | 日本語 | Русский

ErisPulse-WeComAdapter

ErisPulse-WeComAdapter

ErisPulse 企业微信适配器 — 回调接收、应用消息与通讯录 API

PyPI Python License ErisPulse


特性

  • 多账户支持:每个账户对应一个企业微信自建应用,独立 access_token 缓存
  • Webhook 被动接收:自动注册回调路由,处理 URL 验证与消息推送
  • 消息加解密:基于 cryptography 库实现企业微信 AES-256-CBC 加解密与签名验证
  • 丰富消息类型:文本、Markdown、图片、语音、视频、文件、图文、文本卡片、模板卡片
  • OneBot12 标准:事件遵循 OneBot12 规范,平台扩展字段以 wecom_ 前缀标识

安装

epsdk install WeComAdapter

配置

在 config/config.toml 中添加:

[WeComAdapter.accounts.default]
corpid = "你的企业ID"
secret = "你的应用Secret"
agentid = 1000002
token = "回调验证Token"
encoding_aes_key = "回调加解密密钥(43位)"
callback_path = "/wecom/default"
enabled = true

# 多账户示例
[WeComAdapter.accounts.app2]
corpid = "你的企业ID"
secret = "另一个应用的Secret"
agentid = 1000003
token = "回调验证Token"
encoding_aes_key = "回调加解密密钥(43位)"
callback_path = "/wecom/app2"
enabled = true

配置字段

字段 类型 必填 说明
corpid string 是 企业ID(Corpid)
secret string 是 应用 Secret
agentid int 否 应用 AgentID(发送消息时使用)
token string 否 回调验证 Token(企业微信后台设置)
encoding_aes_key string 否 回调加解密密钥 EncodingAESKey(43位)
callback_path string 否 回调接收路径,支持 {account} 占位符(默认 /wecom/{account})
enabled bool 否 是否启用(默认 true)
bot_id string 否 自动取 corpid,无需手动填写

回调地址配置

在企业微信管理后台「自建应用 → 接收消息 → 设置API接收」中,将 URL 填为:

http(s)://<你的服务器地址>:<端口>/wecom/<账户名>

并填入对应的 Token 和 EncodingAESKey。适配器会自动处理 URL 验证(GET)和消息推送(POST)。

快速开始

from ErisPulse import sdk
from ErisPulse.Core.Event import command, message

@command("hello")
async def hello_handler(event):
    await event.reply("Hello from WeCom!")

async def main():
    await sdk.run(keep_running=True)

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

消息发送

所有发送方法通过链式 DSL 调用:

wecom = sdk.adapter.get("wecom")

# 文本消息(私信用户)
await wecom.Send.To("user", "UserID1").Text("Hello World!")

# Markdown 消息
await wecom.Send.To("user", "UserID1").Markdown("**加粗** 消息")

# 发送到群聊(应用群聊)
await wecom.Send.To("group", "ChatID").Text("群消息")

# 图片(支持 media_id 或 bytes 上传)
await wecom.Send.To("user", "UserID1").Image("media_id")
await wecom.Send.To("user", "UserID1").Image(image_bytes, filename="pic.png")

# 图文消息
await wecom.Send.To("user", "UserID1").News([
    {"title": "标题", "description": "描述", "url": "https://example.com", "picurl": "https://example.com/img.jpg"},
])

# 文本卡片
await wecom.Send.To("user", "UserID1").TextCard(
    title="卡片标题", description="卡片描述",
    url="https://example.com", btn_txt="点击查看"
)

# 文件 / 语音 / 视频
await wecom.Send.To("user", "UserID1").File(file_bytes, filename="doc.pdf")
await wecom.Send.To("user", "UserID1").Voice(voice_bytes)
await wecom.Send.To("user", "UserID1").Video(video_bytes)

# 模板卡片
await wecom.Send.To("user", "UserID1").TemplateCard(
    card_type="text_notice",
    main_title={"title": "欢迎使用"},
    emphasis_content={"title": "100", "desc": "处理量"},
    sub_title_text="这是一条模板卡片",
)

# OneBot12 组合消息
ob12_message = [
    {"type": "text", "data": {"text": "你好!"}},
    {"type": "reply", "data": {"message_id": "12345"}},
]
await wecom.Send.To("user", "UserID1").Raw_ob12(ob12_message)

# 多账户指定账户发送
await wecom.Send.To("user", "UserID1", account_id="app2").Text("通过 app2 发送")

发送目标映射

OB12 target_type 企业微信目标 接口
user / private touser(用户消息) message/send
group chatid(应用群聊) appchat/send

依赖

  • cryptography:用于 AES-256-CBC 消息加解密

许可证

MIT License

Metadata

Release files for ErisPulse-WeComAdapter 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ErisPulse-WeComAdapter 0.1.2
File Size Uploaded Provenance Actions
erispulse_wecomadapter-0.1.2.tar.gz 18.1 kB With provenance Details for erispulse_wecomadapter-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ErisPulse-WeComAdapter 0.1.2
File Interpreter ABI Platform Actions
erispulse_wecomadapter-0.1.2-py3-none-any.whl Python 3 none any Details for erispulse_wecomadapter-0.1.2-py3-none-any.whl

Total release size: 37.5 kB

Release files / erispulse_wecomadapter-0.1.2.tar.gz

Download URL erispulse_wecomadapter-0.1.2.tar.gz
Size 18.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6119710e9f3ccad1e1543687c68fdaf96c6e2be8b4f8183f0855f6eb11950979
BLAKE2b-256 checksum
How to use checksums
185881a46d9fe2d0372533931d6dc04fb6751e7a520dcaf4be202df0145166a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / erispulse_wecomadapter-0.1.2-py3-none-any.whl

Download URL erispulse_wecomadapter-0.1.2-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
515d59e5350a9b41392a2702fda17ebfcf22b6b2c4690a737079d45075326ac1
BLAKE2b-256 checksum
How to use checksums
d6c2e10a8850ee77e465e7bbcc23edb46d0f97c6c12e681203d134bdc1608868
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Security for ErisPulse-WeComAdapter 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for erispulse_wecomadapter-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page