Skip to main content

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

markdown from file

You can also provide markdown content from a local file using -f/--file. If both a positional content and -f are provided, the file content takes precedence.

PowerShell example:

# read markdown from file and send
qwsend markdown -f .\path\to\message.md

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_KEY is set in your environment. When that variable is set, running pytest will execute wet tests. There is no separate -m wet tag 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


Download files

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

Source Distribution

qwsend-0.2.1.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

qwsend-0.2.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file qwsend-0.2.1.tar.gz.

File metadata

  • Download URL: qwsend-0.2.1.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qwsend-0.2.1.tar.gz
Algorithm Hash digest
SHA256 5d25ade2a9e992091753a6f47e16b3bf9f9987c6f2fc913776245453938b1cb2
MD5 bc5d81ecd131fadf4f7f237a9c843f1e
BLAKE2b-256 62b3e5bc3998643add78e56f0e364f285f9cd55d160c0dcd8b40375e77c3a0cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for qwsend-0.2.1.tar.gz:

Publisher: release.yml on ZhulongNT/qwsend

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

File details

Details for the file qwsend-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: qwsend-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qwsend-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d505b7334267ccfbfc841502ef4f781072d09c73e17dc57303ac483cd134a926
MD5 9ae7563dab7cd9d80314338c89f894a8
BLAKE2b-256 b821273f0df01827f2a7b04c4867436f32cc07cae3236b7122e3ca834aa7ca94

See more details on using hashes here.

Provenance

The following attestation bundles were made for qwsend-0.2.1-py3-none-any.whl:

Publisher: release.yml on ZhulongNT/qwsend

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