.. figure:: https://img.shields.io/pypi/pyversions/WX-Push-Services?style=plastic
:alt: PyPI - Python Version
.. figure:: https://img.shields.io/pypi/dm/WX-Push-Services
:alt: PyPI - Downloads
.. figure:: https://img.shields.io/pypi/status/WX-Push-Services
:alt: PyPI - Status
.. figure:: https://img.shields.io/pypi/l/WX-Push-Services
:alt: PyPI - License
.. figure:: https://img.shields.io/github/issues-search?query=WX-Push-Services
:alt: GitHub issue custom search
重大更新
==========
目前仓库已在PYPI上发布,可以直接使用pip安装
``pip install wx-push-services``
从现在开始,您可以直接使用命令行推送本地文件内容,具体操作如下:
在推送消息之前,请于环境变量中添加所需变量如后文所示。在命令行环境下,我们也可以直接使用 ``wx-push-services -cf`` 来指定配置文件。如果您不知道如何生成配置文件,请直接执行 ``wx-push-services`` 程序会在当前目录下自动生成。请按照后文填写必要参数,后续可直接运行。
使用 ``wx-push-services -h`` 查看帮助
.. code-block:: python3
wx-push-services -m <"messgage text"> -df <disable message_file mode> -mf <message_file_path> -cf <config_file_path>
# 示例:
wx-push-services -mf message.log
wx-push-services -df -m '"消息测试"'
如果您在集成或使用该项目的过程中有任何问题,欢迎提出,我会尽力解答您的疑问。也可以在该项目的GitHub Repo提出Issue获取帮助。
怎样使用微信以及微信推送服务
============================
- `怎样使用微信以及微信推送服务 <#怎样使用微信以及微信推送服务>`__
- `主要用途 <#主要用途>`__
- `实现微信推送服务的两种方式 <#实现微信推送服务的两种方式>`__
- `使用方式 <#使用方式>`__
- `1. 注册企业微信,获取必要token <#1-注册企业微信获取必要token>`__
- `2. 安装python运行库 <#2-安装python运行库>`__
- `3. 生成并填写配置文件 <#3-生成并填写配置文件>`__
- `4. 运行示例 demo <#4-运行示例demo>`__
- `注意事项 <#注意事项>`__
主要用途
--------
实现微信推送服务的两种方式
--------------------------
1. 调用企业微信应用 使用该种方法时请按照下文方式获得必要token。
2. 使用\ ``web hook``\ 调用企业微信机器人
使用该种方式时仅需要知道企业微信机器人的\ ``web hook key``\ 。在使用之前,请确保已在企业微信群里中添加企业微信机器人,并按照下文方法获得\ ``web hook key``\ 。
使用方式
--------------------------
1. 注册企业微信,获取必要token
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- 使用企业微信应用时获取以下信息:
注册网址:https://work.weixin.qq.com/
1. 获取企业ID
.. figure:: https://s2.loli.net/2023/02/25/9V3l5IGvZiFqMRu.png
在仓库\ ``secrets``\ 中添加如下变量:\ ``CORP_ID=your_id``\
1. 添加应用并获取下述变量
.. figure:: https://s2.loli.net/2023/02/25/XaTm65MjOE3A8iJ.png
.. figure:: https://s2.loli.net/2023/02/25/bkJGwyzZfgIOa7R.png
在仓库\ ``secrets``\ 中添加:\ ``APP_SECRET=your_app_secret``\ 以及\ ``APP_ID=your_app_id``
- 使用机器人\ ``webhook``\ 方式时,请添加以下变量:
.. figure:: https://s2.loli.net/2023/02/25/gOtL3dmJqpBDWIh.png
.. figure:: https://s2.loli.net/2023/02/25/bghHpI3UDvq29lM.png
找到群聊,在其中点击机器人配置,获取\ ``webhookkey``\ 中\ ``key``\ 字段;在仓库中添加\ ``key=your_web_hook_key``\
至此,必要信息已手机完毕。
1. 安装python运行库
~~~~~~~~~~~~~~~~~~~
执行\ ``pip install -r requirments.txt``\
3. 生成并填写配置文件
~~~~~~~~~~~~~~~~~~~~~
初次运行\ ``main.py``\ 中的\ ``demo``\ ,会在当前目录下生成\ ``config.ini``\ 配置文件,如下面代码所示:
.. code:: ini
[Config]
corp_id = your corp_id # Enter your enterprise ID of wechat background here.
app_id = your app_id # Enter your application ID of enterprise wechat background here
app_secret = your app_secret # Enter your application secret of enterprise wechat background here
# 使用APP_PUSH方式时以上必填
# 使用WEB_HOOK_PUSH方式仅需填写下述消息
key = your key # Enter the webhook key of the enterprise's wechat group chat robot here
依次按照\ ``# .......``\ 中的提示填写必要信息。
4. 运行示例\ ``demo``\
~~~~~~~~~~~~~~~~~~~~~~
在\ ``main.py``\ 中再次运行示例\ ``demo``\
.. code:: python
# wxps = APP_PUSH()
hookps = WEB_HOOK_PUSH()
test = (
"# 企业微信消息测试"
+ "## • 二级标题"
+ "## • 测试通过"
)
hookps.send_message(message=test, markdown=False)
即可发送成功,此时可在微信中看到相应信息。
注意事项
---------
**经过测试。markdown信息并不能在微信查看。只能在企业微信查看。所以,如果想要在微信查看,需要将markdown类型消息改为text类型**
Raw data
{
"_id": null,
"home_page": "https://github.com/IronManStank/QYWX_PushService",
"name": "WX-Push-Services",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "wechat,push,message,qywx,wxpusher",
"author": "Super.S",
"author_email": "1157723200@qq.com",
"download_url": "https://files.pythonhosted.org/packages/da/97/edf8405a98d5e7f7d651535e64f0528f2e87a17a45d57565e58ce9794f29/WX_Push_Services-1.0.24.tar.gz",
"platform": "any",
"description": "\r\n.. figure:: https://img.shields.io/pypi/pyversions/WX-Push-Services?style=plastic\r\n :alt: PyPI - Python Version\r\n\r\n.. figure:: https://img.shields.io/pypi/dm/WX-Push-Services\r\n :alt: PyPI - Downloads\r\n\r\n.. figure:: https://img.shields.io/pypi/status/WX-Push-Services\r\n :alt: PyPI - Status\r\n\r\n.. figure:: https://img.shields.io/pypi/l/WX-Push-Services\r\n :alt: PyPI - License\r\n \r\n.. figure:: https://img.shields.io/github/issues-search?query=WX-Push-Services\r\n :alt: GitHub issue custom search\r\n\r\n\r\n\r\n\u91cd\u5927\u66f4\u65b0\r\n==========\r\n\r\n\r\n\u76ee\u524d\u4ed3\u5e93\u5df2\u5728PYPI\u4e0a\u53d1\u5e03\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528pip\u5b89\u88c5\r\n\r\n``pip install wx-push-services``\r\n\r\n\r\n\r\n\u4ece\u73b0\u5728\u5f00\u59cb\uff0c\u60a8\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u547d\u4ee4\u884c\u63a8\u9001\u672c\u5730\u6587\u4ef6\u5185\u5bb9\uff0c\u5177\u4f53\u64cd\u4f5c\u5982\u4e0b\uff1a\r\n\u5728\u63a8\u9001\u6d88\u606f\u4e4b\u524d\uff0c\u8bf7\u4e8e\u73af\u5883\u53d8\u91cf\u4e2d\u6dfb\u52a0\u6240\u9700\u53d8\u91cf\u5982\u540e\u6587\u6240\u793a\u3002\u5728\u547d\u4ee4\u884c\u73af\u5883\u4e0b\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 ``wx-push-services -cf`` \u6765\u6307\u5b9a\u914d\u7f6e\u6587\u4ef6\u3002\u5982\u679c\u60a8\u4e0d\u77e5\u9053\u5982\u4f55\u751f\u6210\u914d\u7f6e\u6587\u4ef6\uff0c\u8bf7\u76f4\u63a5\u6267\u884c ``wx-push-services`` \u7a0b\u5e8f\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u81ea\u52a8\u751f\u6210\u3002\u8bf7\u6309\u7167\u540e\u6587\u586b\u5199\u5fc5\u8981\u53c2\u6570\uff0c\u540e\u7eed\u53ef\u76f4\u63a5\u8fd0\u884c\u3002\r\n\r\n\u4f7f\u7528 ``wx-push-services -h`` \u67e5\u770b\u5e2e\u52a9\r\n\r\n.. code-block:: python3\r\n\r\n wx-push-services -m <\"messgage text\"> -df <disable message_file mode> -mf <message_file_path> -cf <config_file_path>\r\n # \u793a\u4f8b\uff1a\r\n wx-push-services -mf message.log\r\n wx-push-services -df -m '\"\u6d88\u606f\u6d4b\u8bd5\"'\r\n\r\n\r\n\u5982\u679c\u60a8\u5728\u96c6\u6210\u6216\u4f7f\u7528\u8be5\u9879\u76ee\u7684\u8fc7\u7a0b\u4e2d\u6709\u4efb\u4f55\u95ee\u9898,\u6b22\u8fce\u63d0\u51fa,\u6211\u4f1a\u5c3d\u529b\u89e3\u7b54\u60a8\u7684\u7591\u95ee\u3002\u4e5f\u53ef\u4ee5\u5728\u8be5\u9879\u76ee\u7684GitHub Repo\u63d0\u51faIssue\u83b7\u53d6\u5e2e\u52a9\u3002\r\n\r\n\r\n\u600e\u6837\u4f7f\u7528\u5fae\u4fe1\u4ee5\u53ca\u5fae\u4fe1\u63a8\u9001\u670d\u52a1\r\n============================\r\n\r\n- `\u600e\u6837\u4f7f\u7528\u5fae\u4fe1\u4ee5\u53ca\u5fae\u4fe1\u63a8\u9001\u670d\u52a1 <#\u600e\u6837\u4f7f\u7528\u5fae\u4fe1\u4ee5\u53ca\u5fae\u4fe1\u63a8\u9001\u670d\u52a1>`__\r\n- `\u4e3b\u8981\u7528\u9014 <#\u4e3b\u8981\u7528\u9014>`__\r\n- `\u5b9e\u73b0\u5fae\u4fe1\u63a8\u9001\u670d\u52a1\u7684\u4e24\u79cd\u65b9\u5f0f <#\u5b9e\u73b0\u5fae\u4fe1\u63a8\u9001\u670d\u52a1\u7684\u4e24\u79cd\u65b9\u5f0f>`__\r\n- `\u4f7f\u7528\u65b9\u5f0f <#\u4f7f\u7528\u65b9\u5f0f>`__\r\n\r\n - `1. \u6ce8\u518c\u4f01\u4e1a\u5fae\u4fe1\uff0c\u83b7\u53d6\u5fc5\u8981token <#1-\u6ce8\u518c\u4f01\u4e1a\u5fae\u4fe1\u83b7\u53d6\u5fc5\u8981token>`__\r\n - `2. \u5b89\u88c5python\u8fd0\u884c\u5e93 <#2-\u5b89\u88c5python\u8fd0\u884c\u5e93>`__\r\n - `3. \u751f\u6210\u5e76\u586b\u5199\u914d\u7f6e\u6587\u4ef6 <#3-\u751f\u6210\u5e76\u586b\u5199\u914d\u7f6e\u6587\u4ef6>`__\r\n - `4. \u8fd0\u884c\u793a\u4f8b demo <#4-\u8fd0\u884c\u793a\u4f8bdemo>`__\r\n- `\u6ce8\u610f\u4e8b\u9879 <#\u6ce8\u610f\u4e8b\u9879>`__\r\n\r\n\u4e3b\u8981\u7528\u9014\r\n--------\r\n\u5b9e\u73b0\u5fae\u4fe1\u63a8\u9001\u670d\u52a1\u7684\u4e24\u79cd\u65b9\u5f0f\r\n--------------------------\r\n\r\n1. \u8c03\u7528\u4f01\u4e1a\u5fae\u4fe1\u5e94\u7528 \u4f7f\u7528\u8be5\u79cd\u65b9\u6cd5\u65f6\u8bf7\u6309\u7167\u4e0b\u6587\u65b9\u5f0f\u83b7\u5f97\u5fc5\u8981token\u3002\r\n2. \u4f7f\u7528\\ ``web hook``\\ \u8c03\u7528\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba\r\n\r\n \u4f7f\u7528\u8be5\u79cd\u65b9\u5f0f\u65f6\u4ec5\u9700\u8981\u77e5\u9053\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba\u7684\\ ``web hook key``\\ \u3002\u5728\u4f7f\u7528\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u5df2\u5728\u4f01\u4e1a\u5fae\u4fe1\u7fa4\u91cc\u4e2d\u6dfb\u52a0\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba\uff0c\u5e76\u6309\u7167\u4e0b\u6587\u65b9\u6cd5\u83b7\u5f97\\ ``web hook key``\\ \u3002\r\n\r\n\u4f7f\u7528\u65b9\u5f0f\r\n--------------------------\r\n\r\n1. \u6ce8\u518c\u4f01\u4e1a\u5fae\u4fe1\uff0c\u83b7\u53d6\u5fc5\u8981token\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n- \u4f7f\u7528\u4f01\u4e1a\u5fae\u4fe1\u5e94\u7528\u65f6\u83b7\u53d6\u4ee5\u4e0b\u4fe1\u606f\uff1a\r\n\r\n\u6ce8\u518c\u7f51\u5740\uff1ahttps://work.weixin.qq.com/\r\n\r\n1. \u83b7\u53d6\u4f01\u4e1aID\r\n\r\n\r\n.. figure:: https://s2.loli.net/2023/02/25/9V3l5IGvZiFqMRu.png\r\n\r\n\r\n\r\n\u5728\u4ed3\u5e93\\ ``secrets``\\ \u4e2d\u6dfb\u52a0\u5982\u4e0b\u53d8\u91cf\uff1a\\ ``CORP_ID=your_id``\\\r\n\r\n1. \u6dfb\u52a0\u5e94\u7528\u5e76\u83b7\u53d6\u4e0b\u8ff0\u53d8\u91cf\r\n\r\n.. figure:: https://s2.loli.net/2023/02/25/XaTm65MjOE3A8iJ.png\r\n\r\n\r\n.. figure:: https://s2.loli.net/2023/02/25/bkJGwyzZfgIOa7R.png\r\n\r\n\r\n\u5728\u4ed3\u5e93\\ ``secrets``\\ \u4e2d\u6dfb\u52a0\uff1a\\ ``APP_SECRET=your_app_secret``\\ \u4ee5\u53ca\\ ``APP_ID=your_app_id``\r\n\r\n- \u4f7f\u7528\u673a\u5668\u4eba\\ ``webhook``\\ \u65b9\u5f0f\u65f6\uff0c\u8bf7\u6dfb\u52a0\u4ee5\u4e0b\u53d8\u91cf\uff1a\r\n\r\n.. figure:: https://s2.loli.net/2023/02/25/gOtL3dmJqpBDWIh.png\r\n\r\n\r\n.. figure:: https://s2.loli.net/2023/02/25/bghHpI3UDvq29lM.png\r\n\r\n\r\n\u627e\u5230\u7fa4\u804a\uff0c\u5728\u5176\u4e2d\u70b9\u51fb\u673a\u5668\u4eba\u914d\u7f6e\uff0c\u83b7\u53d6\\ ``webhookkey``\\ \u4e2d\\ ``key``\\ \u5b57\u6bb5\uff1b\u5728\u4ed3\u5e93\u4e2d\u6dfb\u52a0\\ ``key=your_web_hook_key``\\\r\n\r\n\u81f3\u6b64\uff0c\u5fc5\u8981\u4fe1\u606f\u5df2\u624b\u673a\u5b8c\u6bd5\u3002\r\n\r\n1. \u5b89\u88c5python\u8fd0\u884c\u5e93\r\n~~~~~~~~~~~~~~~~~~~\r\n\r\n\u6267\u884c\\ ``pip install -r requirments.txt``\\\r\n\r\n\r\n\r\n3. \u751f\u6210\u5e76\u586b\u5199\u914d\u7f6e\u6587\u4ef6\r\n~~~~~~~~~~~~~~~~~~~~~\r\n\r\n\u521d\u6b21\u8fd0\u884c\\ ``main.py``\\ \u4e2d\u7684\\ ``demo``\\ \uff0c\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\\ ``config.ini``\\ \u914d\u7f6e\u6587\u4ef6\uff0c\u5982\u4e0b\u9762\u4ee3\u7801\u6240\u793a\uff1a\r\n\r\n.. code:: ini\r\n\r\n [Config]\r\n corp_id = your corp_id # Enter your enterprise ID of wechat background here.\r\n app_id = your app_id # Enter your application ID of enterprise wechat background here\r\n app_secret = your app_secret # Enter your application secret of enterprise wechat background here\r\n # \u4f7f\u7528APP_PUSH\u65b9\u5f0f\u65f6\u4ee5\u4e0a\u5fc5\u586b\r\n # \u4f7f\u7528WEB_HOOK_PUSH\u65b9\u5f0f\u4ec5\u9700\u586b\u5199\u4e0b\u8ff0\u6d88\u606f\r\n key = your key # Enter the webhook key of the enterprise's wechat group chat robot here\r\n\r\n\u4f9d\u6b21\u6309\u7167\\ ``# .......``\\ \u4e2d\u7684\u63d0\u793a\u586b\u5199\u5fc5\u8981\u4fe1\u606f\u3002\r\n\r\n4. \u8fd0\u884c\u793a\u4f8b\\ ``demo``\\\r\n~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n\u5728\\ ``main.py``\\ \u4e2d\u518d\u6b21\u8fd0\u884c\u793a\u4f8b\\ ``demo``\\\r\n\r\n.. code:: python\r\n\r\n # wxps = APP_PUSH()\r\n hookps = WEB_HOOK_PUSH()\r\n test = (\r\n \"# \u4f01\u4e1a\u5fae\u4fe1\u6d88\u606f\u6d4b\u8bd5\"\r\n + \"## \u2022 \u4e8c\u7ea7\u6807\u9898\"\r\n + \"## \u2022 \u6d4b\u8bd5\u901a\u8fc7\"\r\n )\r\n hookps.send_message(message=test, markdown=False)\r\n\r\n\u5373\u53ef\u53d1\u9001\u6210\u529f\uff0c\u6b64\u65f6\u53ef\u5728\u5fae\u4fe1\u4e2d\u770b\u5230\u76f8\u5e94\u4fe1\u606f\u3002\r\n\r\n\u6ce8\u610f\u4e8b\u9879\r\n---------\r\n**\u7ecf\u8fc7\u6d4b\u8bd5\u3002markdown\u4fe1\u606f\u5e76\u4e0d\u80fd\u5728\u5fae\u4fe1\u67e5\u770b\u3002\u53ea\u80fd\u5728\u4f01\u4e1a\u5fae\u4fe1\u67e5\u770b\u3002\u6240\u4ee5\uff0c\u5982\u679c\u60f3\u8981\u5728\u5fae\u4fe1\u67e5\u770b\uff0c\u9700\u8981\u5c06markdown\u7c7b\u578b\u6d88\u606f\u6539\u4e3atext\u7c7b\u578b**\r\n\r\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Push message to wechat",
"version": "1.0.24",
"project_urls": {
"Homepage": "https://github.com/IronManStank/QYWX_PushService"
},
"split_keywords": [
"wechat",
"push",
"message",
"qywx",
"wxpusher"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cee7312683e41e59344659214f532d44be5331385c7d3cc836e0889e20597c4d",
"md5": "1a8ffe4050ba60504ca367f10acbab26",
"sha256": "f2c99a364eb0d00a2b3eb10964373b8c9716857dd41c02af2e6167dd5d1ef8a1"
},
"downloads": -1,
"filename": "WX_Push_Services-1.0.24-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1a8ffe4050ba60504ca367f10acbab26",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 11351,
"upload_time": "2023-05-17T15:29:25",
"upload_time_iso_8601": "2023-05-17T15:29:25.532441Z",
"url": "https://files.pythonhosted.org/packages/ce/e7/312683e41e59344659214f532d44be5331385c7d3cc836e0889e20597c4d/WX_Push_Services-1.0.24-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "da97edf8405a98d5e7f7d651535e64f0528f2e87a17a45d57565e58ce9794f29",
"md5": "174f8cfbede929c239b047ee7c80160e",
"sha256": "a19eb1ce1a749e51992ece266d5186c1a504387fea13bc36832127767e7912f1"
},
"downloads": -1,
"filename": "WX_Push_Services-1.0.24.tar.gz",
"has_sig": false,
"md5_digest": "174f8cfbede929c239b047ee7c80160e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9168,
"upload_time": "2023-05-17T15:29:27",
"upload_time_iso_8601": "2023-05-17T15:29:27.827200Z",
"url": "https://files.pythonhosted.org/packages/da/97/edf8405a98d5e7f7d651535e64f0528f2e87a17a45d57565e58ce9794f29/WX_Push_Services-1.0.24.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-17 15:29:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "IronManStank",
"github_project": "QYWX_PushService",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "requests",
"specs": [
[
"==",
"2.28.2"
]
]
},
{
"name": "retry2",
"specs": [
[
"==",
"0.9.5"
]
]
}
],
"lcname": "wx-push-services"
}