Wecom(A.K.A. WeChat Work) Group Bot python API.
Project description
pywgb
Wecom(A.K.A. WeChat Work) Group Bot python API.
Homepage
ChowRex/pywgb: Wecom(A.K.A Wechat Work) Group Bot python API.
How to use
-
Create a Wecom Group Bot.
-
Copy the webhook URL or just the
key. It should be like:Webhook: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=UUIDKey: UUID
-
Install this package:
# Normally use this if you won't send voice message pip install -U pywgb # You can install full version by this pip install -U "pywgb[all]"
-
Refer code below:
from pywgb import TextWeComGroupBot, MarkdownWeComGroupBot, ImageWeComGroupBot, NewsWeComGroupBot, FileWeComGroupBot, VoiceWeComGroupBot KEY = "PASTE_YOUR_KEY_OR_WEBHOOKURL_HERE" # If you want to send Text message, use this. msg = "This is a test Text message." bot = TextWeComGroupBot(KEY) bot.send(msg) # If you want to send Markdown message, use this. bot = MarkdownWeComGroupBot(KEY) col = [bot.green, bot.gray, bot.orange] msg = [col[idx % 3](ltr) for idx, ltr in enumerate("colorful")] msg = f"This is a {''.join(msg)} Markdown message" bot.send(msg) # If you want to send Image message, use this. file = "Path/To/Your/Image.png" or "Path/To/Your/Image.jpg" bot = ImageWeComGroupBot(KEY) bot.send(file_path=file) # If you want to send News message, use this. articles = [ { "title": "This is a test news", "description": "You can add description here", "url": "www.tencent.com", # Here is the link of picture "picurl": "https://www.tencent.com/img/index/tencent_logo.png" }, ] bot = NewsWeComGroupBot(KEY) bot.send(articles=articles) # If you want to send File message, use this. file = "Path/To/Your/File.suffix" bot = FileWeComGroupBot(KEY) bot.send(file_path=file) # If you want to send Voice message, use this. file = "Path/To/Your/Voice.amr" # BE ADVISED: ONLY support amr file bot = VoiceWeComGroupBot(KEY) bot.send(file_path=file)
-
Send template card messages (Advanced usage)
from pywgb import TextCardWeComGroupBot KEY = "PASTE_YOUR_KEY_OR_WEBHOOKURL_HERE" # Prepare the card content kwargs = { "main_title": { "title": "Test message", "desc": "This is a test template text card message" }, "emphasis_content": { "title": "100", "desc": "No meaning" }, "quote_area": { "type": 1, "url": "https://work.weixin.qq.com/?from=openApi", "title": "Title reference", "quote_text": "Hello\nWorld!" }, "sub_title_text": "This is sub-title", "horizontal_content_list": [{ "keyname": "Author", "value": "Rex" }, { "keyname": "Google", "value": "Click to go", "type": 1, "url": "https://google.com" }], "jump_list": [{ "type": 1, "url": "https://bing.com", "title": "Bing" }], "card_action": { "type": 1, "url": "https://work.weixin.qq.com/?from=openApi", } } bot = TextCardWeComGroupBot(KEY) bot.send(**kwargs)
Official Docs
Only Chinese doc: 群机器人配置说明 - 文档 - 企业微信开发者中心
Roadmap
-
v0.0.1: 🎉 Initial project. Offering send
TextandMarkdowntype message. -
v0.0.2: 🖼️ Add
Imagetype message support;- Add overheat detect function and unified exception handling
-
v0.0.3: 📰 Add
Newstype message support;- Move bots into a new module:
bot
- Move bots into a new module:
-
v0.0.4: 📂 Add
Filetype message support;- Refactor
botmodule
- Refactor
-
v0.0.5: 🗣️ Add
Voicetype message support.- Refactor
decomodule - Add
verify_filedecorator - Introverted parameters check errors
- Add more content into README.md
- Refactor
-
v0.0.6: 🩹 Add
VoiceandFiletype size check. -
v0.0.7: 🗒️ Add
TextCardtype message support. -
v0.0.8: 🗃️ Add
NewsCardtype message support. -
v0.1.0: 👍 First FULL capacity stable version release.Fix bugs and so on.
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 pywgb-0.0.7.tar.gz.
File metadata
- Download URL: pywgb-0.0.7.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44d789113e7d0b1e379a480f59a1c480e2faac2eb5d8af1f1d3b52fabaae0339
|
|
| MD5 |
dec804f8bdecf76081bc27532770961a
|
|
| BLAKE2b-256 |
e605885db1294cb8163fada92e8928bde40609d0b929bfa0af69e82f83a3d7f3
|
File details
Details for the file pywgb-0.0.7-py3-none-any.whl.
File metadata
- Download URL: pywgb-0.0.7-py3-none-any.whl
- Upload date:
- Size: 17.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06f9b649a8a127f7a130894db0637314cb53030ab11713a63b7b4a945a1bfcb8
|
|
| MD5 |
630ca1d2508ec7159c4122b35d453dc7
|
|
| BLAKE2b-256 |
5f3d3e72f9a7884e9da5c0891dba2f9b19fcbc8381b2a97da769869783614bd8
|