Skip to main content

send message to wechat robot

Project description

功能

  • 发送消息到企业微信机器人。
  • 支持所有企业微信机器人消息类型。
  • 企业微信机器人

安装

1. 安装该模块
pip install wechatrobot

使用

  • 获取微信机器人的 key

    创建机器人时,会返回一个 webhook 的地址,如 https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=5cb94c2b-1238-4414-b830-a521523d7a,则 key5cb94c2b-1238-4414-b830-a521523d7a

  • 使用

    key = '5cb94c2b-1238-4414-b830-a521523d7a'
    
    import wechatrobot
    wxrobot = wechatrobot.WechatRobot(key)
    
  • 发送文本消息

    # 签名
    wxrobot.send_text(content, at_mobiles=None)
    
    # content 为要发送的文本内容
    # at_mobiles 需要 @ 人的手机号,可以是列表或字符串(多个人使用逗号分隔)。如果要 @所有人,则设置 at_mobiles='all'。@ 多个人时,指定 at_mobiles='18600000000,18600000001'
    
  • 发送 markdown 消息

    # 签名
    wxrobot.send_markdown(contents)
    
    # 如果 contents 为列表、元组, 每一行为一个 markdown 格式的字符串。默认会在每个元素后增加一个 '\n' 换行符。
    # 如果 contents 是字符串,则用户自己控制markdown的格式。
    # 支持的格式参考:https://work.weixin.qq.com/api/doc/90000/90136/91770#markdown%E7%B1%BB%E5%9E%8B
    
  • 发送图片

    # 签名
    wxrobot.send_image(image_path)
    
    # image_path 支持 HTTP、HTTPS、FTP,互联网上的图片URL。也支持本地的图片路径。
    # 如 wxrobot.send_image('https://img1.maka.im/template/T_G29KRHKN_t1.jpg')
    
  • 发送图文类型

    # 签名
    wxrobot.send_news(news_title, jump_url, picurl=None, news_description=None)
    
    # news_title          消息标题
    # jump_url            跳转url
    # picurl              图片的url
    # news_description    消息描述
    
  • 发送文件

    # 签名
    wxrobot.send_file(file_path)
    
    # file_path   要上传的本地文件路径。大小不能超过20M
    

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

wechatrobot-1.0.6-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file wechatrobot-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: wechatrobot-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.2

File hashes

Hashes for wechatrobot-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 46e4ca4875743e0584606953099f17e35a5a82b9ca0c1f8c084b4a220be4a691
MD5 f8de66b918317f4442dc3b7ad1b85243
BLAKE2b-256 7aa1738acb8d8b16a4537370ebe8cb18409f0f0c4be7cf768a10b3b25f6972f9

See more details on using hashes here.

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