Skip to main content
PyPI - Python Version
PyPI - Downloads
PyPI - Status
PyPI - License
GitHub issue custom search

重大更新

目前仓库已在PYPI上发布,可以直接使用pip安装

pip install wx-push-services

从现在开始,您可以直接使用命令行推送本地文件内容,具体操作如下: 在推送消息之前,请于环境变量中添加所需变量如后文所示。在命令行环境下,我们也可以直接使用 wx-push-services -cf 来指定配置文件。如果您不知道如何生成配置文件,请直接执行 wx-push-services 程序会在当前目录下自动生成。请按照后文填写必要参数,后续可直接运行。

使用 wx-push-services -h 查看帮助

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。

  2. 使用web hook调用企业微信机器人

    使用该种方式时仅需要知道企业微信机器人的web hook key。在使用之前,请确保已在企业微信群里中添加企业微信机器人,并按照下文方法获得web hook key。

使用方式

1. 注册企业微信,获取必要token

  • 使用企业微信应用时获取以下信息:

注册网址:https://work.weixin.qq.com/

  1. 获取企业ID

https://s2.loli.net/2023/02/25/9V3l5IGvZiFqMRu.png

在仓库secrets中添加如下变量:CORP_ID=your_id

  1. 添加应用并获取下述变量

https://s2.loli.net/2023/02/25/XaTm65MjOE3A8iJ.png
https://s2.loli.net/2023/02/25/bkJGwyzZfgIOa7R.png

在仓库secrets中添加:APP_SECRET=your_app_secret以及APP_ID=your_app_id

  • 使用机器人webhook方式时,请添加以下变量:

https://s2.loli.net/2023/02/25/gOtL3dmJqpBDWIh.png
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配置文件,如下面代码所示:

[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

# wxps = APP_PUSH()
hookps = WEB_HOOK_PUSH()
test = (
    "# 企业微信消息测试"
    + "## •  二级标题"
    + "## •  测试通过"
)
hookps.send_message(message=test, markdown=False)

即可发送成功,此时可在微信中看到相应信息。

注意事项

经过测试。markdown信息并不能在微信查看。只能在企业微信查看。所以,如果想要在微信查看,需要将markdown类型消息改为text类型

Release files for WX-Push-Services 1.0.24

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for WX-Push-Services 1.0.24
File Size Uploaded
WX_Push_Services-1.0.24.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for WX-Push-Services 1.0.24
File Interpreter ABI Platform
WX_Push_Services-1.0.24-py3-none-any.whl Python 3 none any Details

Total release size: 20.5 kB

Release files / WX_Push_Services-1.0.24.tar.gz

Download URL WX_Push_Services-1.0.24.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a19eb1ce1a749e51992ece266d5186c1a504387fea13bc36832127767e7912f1
BLAKE2b-256 checksum
How to use checksums
da97edf8405a98d5e7f7d651535e64f0528f2e87a17a45d57565e58ce9794f29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / WX_Push_Services-1.0.24-py3-none-any.whl

Download URL WX_Push_Services-1.0.24-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2c99a364eb0d00a2b3eb10964373b8c9716857dd41c02af2e6167dd5d1ef8a1
BLAKE2b-256 checksum
How to use checksums
cee7312683e41e59344659214f532d44be5331385c7d3cc836e0889e20597c4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

This release

1.0.24 This release

2 release files

1.0.23

2 release files

1.0.22

2 release files

1.0.21

2 release files

1.0.20

2 release files

1.0.19

2 release files

1.0.18

2 release files

1.0.17

1 release file

1.0.16

1 release file

1.0.14

1 release file

1.0.13

1 release file

1.0.12

1 release file

1.0.11

1 release file

1.0.10

1 release file

1.0.9

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page