企业微信机器人
Project description
Work Weixin Robot
企业微信机器人
Installation
pip install WorkWeixinRobot
Usage
Command
Usage: wwx-robot -k <robot_key> -t <msg_type> -d <msg_data> -f <msg_file_path>
Option:
-k Robot key
-t Message type
text, markdown, image, news
-d Message data
-f Message file
It should be text file if message type is text
It should be markdown file if message type is markdown
It should be image file if message type is image
It should be YAML file if message type is news
Example:
wwx-robot -k xxxx -t text -d "Hello world"
wwx-robot -k xxxx -t markdown -f ./hello.md
wwx-robot -k xxxx -t image -f ./picture.png
wwx-robot -k xxxx -t news -f ./articles.yaml
Message File Template:
hello.md
## Weixin MSG
Hello, World
articles.yaml
- title: 'Article I'
description: 'Article I Description' # Optional
url: 'URL I'
picurl: 'Article I Picture URL' # Optional
- title: 'Article II'
description: 'Article II Description' # Optional
url: 'URL II'
picurl: 'Article II Picture URL' # Optional
Python
Init a weixin robot
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from WorkWeixinRobot.work_weixin_robot import WWXRobot
wwxrbt = WWXRobot(key='Robot Key')
Send Text Message
wwxrbt.send_text(content='Hello')
Send Markdown Message
wwxrbt.send_markdown(content='Hello')
Send Image Message
# Method I: Send local image
wwxrbt.send_image(local_file='local_image.jpg')
# Method II: Send remote URL image
wwxrbt.send_image(remote_url='http://www.baoxian-sz.com/wp-content/uploads/2019/07/logo_logo_zhenxinhuaxian_tiw_600_150.png')
Send Articles Message [ Image + Text ]
articles = [
{
'title': 'Article I',
'description': 'Article I Description', # Optional
'url': 'URL I',
'picurl': 'Article I Picture URL', # Optional
},
{
'title': 'Article II',
'description': 'Article II Description', # Optional
'url': 'URL II',
'picurl': 'Article II Picture URL', # Optional
}
]
wwxrbt.send_news(articles=articles)
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
WorkWeixinRobot-0.2.1.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for WorkWeixinRobot-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f902b4468ac7ffcb7676416a5d29a522134ae3867f06364aad8b2f733faf733 |
|
MD5 | e13d459306265d361a030d879fa92d8d |
|
BLAKE2b-256 | 6b7fe27a8ac804c09130d9efc50b5edf3e4aedfbecd66599b110f897fe563add |