A lightweight WeCom (WeChat Work) webhook client using httpx with custom User-Agent
Project description
qwsend
WeCom (企业微信) webhook client based on httpx with a clear, reusable API. It sets a custom User-Agent built from the project name and version.
- Sync and async clients
- Message types: text, markdown/markdown_v2, image, news, file, voice, template_card
- Media upload helper (file/voice)
- Simple CLI:
qwsend "hello" --key <key>
Install
pip install qwsend
Quick start
CLI:
The CLI now uses subcommands to select the message type. Set the key either via --key or the environment variable QWSEND_WEBHOOK_KEY.
Examples (PowerShell):
# preferred: supply key per-invocation (or set the env var once as shown below)
qwsend --key "<your_key>" text "hello from CLI"
# or set the environment variable for the session:
$env:QWSEND_WEBHOOK_KEY = "<your_key>"
# text with mentions (repeatable --mention)
qwsend text "hi everyone" --mention user1 --mention user2
# markdown (use --v2 for markdown_v2)
qwsend markdown "**bold** and _italic_" --v2
# send image from a local file (use -f / --file)
qwsend image -f .\path\to\image.jpg
# send news (JSON file containing an articles list)
qwsend news -f .\path\to\articles.json
# upload then send a file (CLI uploads then sends the file)
qwsend file -f .\path\to\file.pdf
# upload then send a voice file (CLI uploads then sends the voice)
qwsend voice -f .\path\to\audio.amr
# send template_card from a JSON file
qwsend template-card -f .\path\to\template.json
Sync:
from qwsend import WebhookClient
client = WebhookClient(key="<your_key>")
client.send_text("hello world")
client.send_markdown("**bold**")
client.close()
Async:
import asyncio
from qwsend import AsyncWebhookClient
async def main():
client = AsyncWebhookClient(key="<your_key>")
await client.send_text("hello async")
await client.aclose()
asyncio.run(main())
User-Agent
The client uses a UA like: qwsend/0.1.0 (+https://pypi.org/project/qwsend/).
Tests
- Dry tests: run without network (recommended during development)
- Wet tests: live webhook calls — enabled when
QWSEND_WEBHOOK_KEYis set in your environment. When that variable is set, runningpytestwill execute wet tests. There is no separate-m wettag required now.
# run dry-only tests
pytest
# run all tests (will include wet/live tests if QWSEND_WEBHOOK_KEY is set)
export QWSEND_WEBHOOK_KEY="fakexxxx-7aoc-4bc4-97a0-0ec2sifa5aaa"
pytest
Packaging
This project uses pyproject.toml with setuptools. Build and publish:
python -m build
python -m twine upload dist/*
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 qwsend-0.2.0.tar.gz.
File metadata
- Download URL: qwsend-0.2.0.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2da97eeb2126800859c9f9fa86cb94315d6bca21e0bea74163c13540ab2c89d7
|
|
| MD5 |
7d922200f5058074ba31f8ed9665e8bb
|
|
| BLAKE2b-256 |
e84b5ab6fbb1314e2bcc3ebd8ffa5c9d7ec17bf08c33649b14909da7d1fd3ecf
|
Provenance
The following attestation bundles were made for qwsend-0.2.0.tar.gz:
Publisher:
release.yml on ZhulongNT/qwsend
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qwsend-0.2.0.tar.gz -
Subject digest:
2da97eeb2126800859c9f9fa86cb94315d6bca21e0bea74163c13540ab2c89d7 - Sigstore transparency entry: 630334378
- Sigstore integration time:
-
Permalink:
ZhulongNT/qwsend@5c22c7f0868e10b5e8c4424b3c34fbb81d9c5052 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ZhulongNT
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5c22c7f0868e10b5e8c4424b3c34fbb81d9c5052 -
Trigger Event:
release
-
Statement type:
File details
Details for the file qwsend-0.2.0-py3-none-any.whl.
File metadata
- Download URL: qwsend-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c25d8380d616db205911cf733979b32cdaf500f217d8b99f4bd57089d6bf8c5b
|
|
| MD5 |
4c4078914c4f888cfe4d1d9bea2b4f15
|
|
| BLAKE2b-256 |
d50bab5302cbef0ac401012f12d14b58940f74aaf5eef48cdec07b1694b7576e
|
Provenance
The following attestation bundles were made for qwsend-0.2.0-py3-none-any.whl:
Publisher:
release.yml on ZhulongNT/qwsend
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qwsend-0.2.0-py3-none-any.whl -
Subject digest:
c25d8380d616db205911cf733979b32cdaf500f217d8b99f4bd57089d6bf8c5b - Sigstore transparency entry: 630334382
- Sigstore integration time:
-
Permalink:
ZhulongNT/qwsend@5c22c7f0868e10b5e8c4424b3c34fbb81d9c5052 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ZhulongNT
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5c22c7f0868e10b5e8c4424b3c34fbb81d9c5052 -
Trigger Event:
release
-
Statement type: