Skip to main content

WeChatBot Send Message

Project description

Python使用微信机器人发送消息

微信群机器人官方文档:https://developer.work.weixin.qq.com/document/path/91770

如何创建微信机器人并获取Key

其中"key="后面的xxxxxx,就是该微信机器人对应的key

如何下载安装&更新

pip install PyWeChatBot
# pip install --upgrade PyWeChatBot

# 如果遇到安装报错,一般可以通过更新pip后重新执行解决
# python -m pip install --upgrade pip

如何使用微信机器人发送消息

1.创建微信机器人

from wechatbot.wechat_bot import WeChatBot
# 输入根据上面方式所创建的机器人对应的Key
wx_key = "xxx"
# 初始化微信机器人
wx = WeChatBot(wx_key)

2.发送文本类型的消息

wx.send_text("准备吃午饭啦~~~")

3.发送markdown类型的消息

wx.send_markdown("""实时新增用户反馈<font color=\"warning\">132例</font>,请相关同事注意。\n
         >类型:<font color=\"comment\">用户反馈</font>
         >普通用户反馈:<font color=\"comment\">117例</font>
         >VIP用户反馈:<font color=\"comment\">15例</font>""")

4.发送图片类型的消息

wx.send_image(r"./my_pic.png")
wx.send_image("http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png")

5.发送图文类型的消息

wx.send_news(title="该摸鱼了", url="zhihu.com", picurl="https://img0.baidu.com/it/u=490071974,3856819170&fm=253&fmt=auto&app=120&f=JPEG?w=608&h=304",
             description="是时候休息一下了")

6.上传并发送文件

resp = wx.upload_media_file('file', r'./test.txt')
wx.send_file(resp['media_id'])

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

PyWeChatBot-0.0.8.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

PyWeChatBot-0.0.8-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file PyWeChatBot-0.0.8.tar.gz.

File metadata

  • Download URL: PyWeChatBot-0.0.8.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.1

File hashes

Hashes for PyWeChatBot-0.0.8.tar.gz
Algorithm Hash digest
SHA256 ab8c05da313cff5feada41e68874da79a4939bf5ceaec6cf8c3423db7c9f91c3
MD5 911e58698f45c090954a90e7838badd5
BLAKE2b-256 63fa8368608911a749978401b70287302669929070cea370a9aa0be72eb02b79

See more details on using hashes here.

File details

Details for the file PyWeChatBot-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: PyWeChatBot-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.1

File hashes

Hashes for PyWeChatBot-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 b5464ed85b05b9b1edabdbb3d9f85c325c7f0e51c876c83b7bb9d3277e64ea06
MD5 b7486ed17ea1be22799d8f93090ea4bf
BLAKE2b-256 1b007e6f9cd3ec259f868af3704cb14e47042fe5a8872709359f5539b8fa99b8

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