Skip to main content

企业微信机器人

Project description

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
            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)

Uploaded Source

Built Distribution

WorkWeixinRobot-0.2.1-py3-none-any.whl (5.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page