Skip to main content

轻量级企业微信消息发送库

Project description

wecom-lite

轻量级企业微信消息发送库,支持发送文本、图片、文件、文本卡片和Markdown等消息。

安装

pip install wecom-lite

使用示例

from wecom_lite import WeChat

# 首先创建 .env 文件配置您的企业微信信息
# 参见 .env.example

wechat = WeChat()
wechat.send_text("测试消息")

配置

创建 .env 文件,包含以下内容:

WECOM_CORP_ID = '您的企业ID'
WECOM_AGENT_ID = '应用ID'
WECOM_SECRET = '应用Secret'
WECOM_TOUSER = '接收消息的用户ID'

功能特点

  • 支持多种消息类型:
    • 文本消息
    • 图片消息
    • 文件消息
    • 文本卡片
    • Markdown
  • 自动处理访问令牌
  • 简单易用的API
  • 内置日志记录功能,记录所有发送的消息及返回结果

日志功能

wecom-lite 自动记录所有发送消息的详情和返回结果。日志文件存储在项目根目录的 logs 文件夹中:

  • wecom.log: 包含基本的发送记录
  • wecom_details_YYYYMMDD.log: 包含每天详细的发送记录,包括完整的消息内容和返回结果

示例日志内容:

2023-05-08 10:58:25,123 - INFO - 发送text消息成功: {"timestamp": "2023-05-08 10:58:25", "msg_type": "text", "content": "测试消息", "result": {"errcode": 0, "errmsg": "ok"}, "touser": "UserID", "agent_id": 1000001}

开发

安装开发依赖

pip install -e ".[dev]"

运行测试

pytest

许可

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wecom_lite-0.1.3-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file wecom_lite-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: wecom_lite-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for wecom_lite-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 66f7f0dd68a6da0d76bc7f6f767f06864a32a2d74a68e00b46b3cecf6dbc4f92
MD5 68c92f52bf18eea6af71105e0929b60a
BLAKE2b-256 51f77d0c19e58515e1f694282d5e2ced86020165a20dd93b56d8f459f3fbce5b

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