WorkWeixinRobot

企业微信群机器人


License
MIT
Install
pip install WorkWeixinRobot==1.0.1

Documentation

Work Weixin Robot

企业微信群机器人

Org Author License python PyPI Ref

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
              +--------------+--------------+
              | Message Type |  File Type   |
              +--------------+--------------+
              |     text     |     text     |
              +--------------+--------------+
              |   markdown   |   markdown   |
              +--------------+--------------+
              |     image    |    jpg,png   |
              +--------------+--------------+
              |     news     |     yaml     |
              +--------------+--------------+
Example:
    wwx-robot -k xxxx -t text -d "Hello world"
    wwx-robot -k xxxx -t markdown -f demo/help.md
    wwx-robot -k xxxx -t image -f demo/picture.jpg
    wwx-robot -k xxxx -t news -f demo/articles.yaml

Message File Template:
    help.md
      ## Weixin MSG
      How to use this tool
    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='https://office.baoxian-sz.com/assets/img/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)