轻量级企业微信消息发送库
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wecom_lite-0.1.1-py3-none-any.whl.
File metadata
- Download URL: wecom_lite-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
192ed615cc11bafe2a28ef042de1bc7cf964f8df883f75da846de5e83dd11c62
|
|
| MD5 |
2ccab8d66bc308e9e13df04d3292963b
|
|
| BLAKE2b-256 |
8568f969788e2cbccdfe5fb98b03db8f94f12c2dde0bf698e979c8da8e2823e7
|