PyWeChatBot


NamePyWeChatBot JSON
Version 0.0.8 PyPI version JSON
download
home_pagehttps://github.com/xuranyang/PyWeChatBot
SummaryWeChatBot Send Message
upload_time2024-08-31 17:59:52
maintainerNone
docs_urlNone
authorxuranyang
requires_python>=3.7
licenseMIT
keywords wechat bot wechatbot wechat bot
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
## Python使用微信机器人发送消息
微信群机器人官方文档:https://developer.work.weixin.qq.com/document/path/91770

### 如何创建微信机器人并获取Key
![](img/add_bot.png)
![](img/bot_key.png)
> 其中"key="后面的xxxxxx,就是该微信机器人对应的key

### 如何下载安装&更新
```
pip install PyWeChatBot
# pip install --upgrade PyWeChatBot

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

### 如何使用微信机器人发送消息
#### 1.创建微信机器人
```pyhton
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'])
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/xuranyang/PyWeChatBot",
    "name": "PyWeChatBot",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "wechat, bot, wechatbot, wechat bot",
    "author": "xuranyang",
    "author_email": "xuranyang96@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/63/fa/8368608911a749978401b70287302669929070cea370a9aa0be72eb02b79/PyWeChatBot-0.0.8.tar.gz",
    "platform": null,
    "description": "\n## Python\u4f7f\u7528\u5fae\u4fe1\u673a\u5668\u4eba\u53d1\u9001\u6d88\u606f\n\u5fae\u4fe1\u7fa4\u673a\u5668\u4eba\u5b98\u65b9\u6587\u6863\uff1ahttps://developer.work.weixin.qq.com/document/path/91770\n\n### \u5982\u4f55\u521b\u5efa\u5fae\u4fe1\u673a\u5668\u4eba\u5e76\u83b7\u53d6Key\n![](img/add_bot.png)\n![](img/bot_key.png)\n> \u5176\u4e2d\"key=\"\u540e\u9762\u7684xxxxxx\uff0c\u5c31\u662f\u8be5\u5fae\u4fe1\u673a\u5668\u4eba\u5bf9\u5e94\u7684key\n\n### \u5982\u4f55\u4e0b\u8f7d\u5b89\u88c5&\u66f4\u65b0\n```\npip install PyWeChatBot\n# pip install --upgrade PyWeChatBot\n\n# \u5982\u679c\u9047\u5230\u5b89\u88c5\u62a5\u9519,\u4e00\u822c\u53ef\u4ee5\u901a\u8fc7\u66f4\u65b0pip\u540e\u91cd\u65b0\u6267\u884c\u89e3\u51b3\n# python -m pip install --upgrade pip\n```\n\n### \u5982\u4f55\u4f7f\u7528\u5fae\u4fe1\u673a\u5668\u4eba\u53d1\u9001\u6d88\u606f\n#### 1.\u521b\u5efa\u5fae\u4fe1\u673a\u5668\u4eba\n```pyhton\nfrom wechatbot.wechat_bot import WeChatBot\n# \u8f93\u5165\u6839\u636e\u4e0a\u9762\u65b9\u5f0f\u6240\u521b\u5efa\u7684\u673a\u5668\u4eba\u5bf9\u5e94\u7684Key\nwx_key = \"xxx\"\n# \u521d\u59cb\u5316\u5fae\u4fe1\u673a\u5668\u4eba\nwx = WeChatBot(wx_key)\n```\n\n#### 2.\u53d1\u9001\u6587\u672c\u7c7b\u578b\u7684\u6d88\u606f\n```\nwx.send_text(\"\u51c6\u5907\u5403\u5348\u996d\u5566~~~\")\n```\n\n#### 3.\u53d1\u9001markdown\u7c7b\u578b\u7684\u6d88\u606f\n```\nwx.send_markdown(\"\"\"\u5b9e\u65f6\u65b0\u589e\u7528\u6237\u53cd\u9988<font color=\\\"warning\\\">132\u4f8b</font>\uff0c\u8bf7\u76f8\u5173\u540c\u4e8b\u6ce8\u610f\u3002\\n\n         >\u7c7b\u578b:<font color=\\\"comment\\\">\u7528\u6237\u53cd\u9988</font>\n         >\u666e\u901a\u7528\u6237\u53cd\u9988:<font color=\\\"comment\\\">117\u4f8b</font>\n         >VIP\u7528\u6237\u53cd\u9988:<font color=\\\"comment\\\">15\u4f8b</font>\"\"\")\n```\n\n#### 4.\u53d1\u9001\u56fe\u7247\u7c7b\u578b\u7684\u6d88\u606f\n```\nwx.send_image(r\"./my_pic.png\")\nwx.send_image(\"http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png\")\n```\n\n#### 5.\u53d1\u9001\u56fe\u6587\u7c7b\u578b\u7684\u6d88\u606f\n```\nwx.send_news(title=\"\u8be5\u6478\u9c7c\u4e86\", url=\"zhihu.com\", picurl=\"https://img0.baidu.com/it/u=490071974,3856819170&fm=253&fmt=auto&app=120&f=JPEG?w=608&h=304\",\n             description=\"\u662f\u65f6\u5019\u4f11\u606f\u4e00\u4e0b\u4e86\")\n```\n\n\n#### 6.\u4e0a\u4f20\u5e76\u53d1\u9001\u6587\u4ef6\n```\nresp = wx.upload_media_file('file', r'./test.txt')\nwx.send_file(resp['media_id'])\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "WeChatBot Send Message",
    "version": "0.0.8",
    "project_urls": {
        "Homepage": "https://github.com/xuranyang/PyWeChatBot"
    },
    "split_keywords": [
        "wechat",
        " bot",
        " wechatbot",
        " wechat bot"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1b007e6f9cd3ec259f868af3704cb14e47042fe5a8872709359f5539b8fa99b8",
                "md5": "b7486ed17ea1be22799d8f93090ea4bf",
                "sha256": "b5464ed85b05b9b1edabdbb3d9f85c325c7f0e51c876c83b7bb9d3277e64ea06"
            },
            "downloads": -1,
            "filename": "PyWeChatBot-0.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b7486ed17ea1be22799d8f93090ea4bf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 5970,
            "upload_time": "2024-08-31T17:59:51",
            "upload_time_iso_8601": "2024-08-31T17:59:51.084727Z",
            "url": "https://files.pythonhosted.org/packages/1b/00/7e6f9cd3ec259f868af3704cb14e47042fe5a8872709359f5539b8fa99b8/PyWeChatBot-0.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "63fa8368608911a749978401b70287302669929070cea370a9aa0be72eb02b79",
                "md5": "911e58698f45c090954a90e7838badd5",
                "sha256": "ab8c05da313cff5feada41e68874da79a4939bf5ceaec6cf8c3423db7c9f91c3"
            },
            "downloads": -1,
            "filename": "PyWeChatBot-0.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "911e58698f45c090954a90e7838badd5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 5313,
            "upload_time": "2024-08-31T17:59:52",
            "upload_time_iso_8601": "2024-08-31T17:59:52.383525Z",
            "url": "https://files.pythonhosted.org/packages/63/fa/8368608911a749978401b70287302669929070cea370a9aa0be72eb02b79/PyWeChatBot-0.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-31 17:59:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xuranyang",
    "github_project": "PyWeChatBot",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pywechatbot"
}
        
Elapsed time: 0.95571s