perk-pushplus-sdk 1.2.3__tar.gz → 1.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/PKG-INFO +13 -2
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/README.md +12 -1
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/pyproject.toml +1 -1
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/__init__.py +5 -1
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/__init__.py +2 -0
- perk_pushplus_sdk-1.2.4/src/perk_pushplus/api/cmcc.py +38 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/client.py +2 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/config.py +1 -1
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/enums.py +2 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/__init__.py +3 -0
- perk_pushplus_sdk-1.2.4/src/perk_pushplus/models/open_cmcc.py +28 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus_sdk.egg-info/PKG-INFO +13 -2
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus_sdk.egg-info/SOURCES.txt +2 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/tests/test_enums_and_exceptions.py +1 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/tests/test_open_api.py +28 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/setup.cfg +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/access_key.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/access_key.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/base.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/channel.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/clawbot.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/doc.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/excel.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/form.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/forward_log.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/forward_rule.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/friend.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/image.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/message.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/message_token.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/open_message.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/pre.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/qqbot.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/setting.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/topic.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/topic_user.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/user.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/api/webhook.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/callback_parser.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/exceptions.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/http.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/base.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/callback.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_access.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_channel.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_clawbot.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_doc.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_form.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_forward.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_friend.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_image.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_message.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_pre.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_qqbot.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_setting.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_token.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_topic.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_user.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_webhook.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/send.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/multipart.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/py.typed +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/rate_limit.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus_sdk.egg-info/dependency_links.txt +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus_sdk.egg-info/requires.txt +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus_sdk.egg-info/top_level.txt +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/tests/test_image_api.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/tests/test_message_api.py +0 -0
- {perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/tests/test_models.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: perk-pushplus-sdk
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.4
|
|
4
4
|
Summary: pushplus(推送加) 官方接口的 Python SDK,覆盖消息发送接口与全部开放接口。
|
|
5
5
|
Author: perk-net
|
|
6
6
|
License: Apache-2.0
|
|
@@ -35,7 +35,7 @@ Requires-Dist: responses>=0.23; extra == "dev"
|
|
|
35
35
|
[pushplus(推送加)](https://www.pushplus.plus) 官方接口的 Python SDK,覆盖 **消息接口** 与 **全部开放接口**。
|
|
36
36
|
|
|
37
37
|
- **消息接口**(`/send`、`/batchSend`):单渠道 + 多渠道发送,含 Builder API。
|
|
38
|
-
- **开放接口**(`/api/open/...` 与 `/push/api/open/...`):用户、消息、消息 token、群组、群组用户、好友、webhook、渠道、ClawBot、QQ 机器人、功能设置、预处理信息、图片服务、push 表单、push 文档、push 表格、消息规则。
|
|
38
|
+
- **开放接口**(`/api/open/...` 与 `/push/api/open/...`):用户、消息、消息 token、群组、群组用户、好友、webhook、渠道、ClawBot、新消息 ClawBot、QQ 机器人、功能设置、预处理信息、图片服务、push 表单、push 文档、push 表格、消息规则。
|
|
39
39
|
- **AccessKey 自动管理**:缓存 + 过期前自动刷新;`code=401` 自动刷新并重试一次。
|
|
40
40
|
- **本地限流守卫**:命中 `code=900` 后按 token 短路同 token 后续发送,避免被服务端长期封禁。
|
|
41
41
|
- **回调解析**:`message_complate`、`add_topic_user`、`add_friend` 三类回调统一解析。
|
|
@@ -168,6 +168,17 @@ topic_blacklist = client.topic_user.blacklist_list(TopicUserListQuery.of(1, 20,
|
|
|
168
168
|
# webhook 渠道
|
|
169
169
|
webhooks = client.webhook.list()
|
|
170
170
|
|
|
171
|
+
# 新消息 ClawBot:绑定 Channel API Key 后,channel 传 cmcc(仅中国移动)
|
|
172
|
+
client.cmcc.bind("ak_xxxxxxxxxxxxxxxx")
|
|
173
|
+
cmcc_info = client.cmcc.info() # cmcc_info.bound == 1 表示已绑定
|
|
174
|
+
client.cmcc.send_test()
|
|
175
|
+
client.send(SendRequest(
|
|
176
|
+
title="服务告警",
|
|
177
|
+
content="订单服务响应超时",
|
|
178
|
+
channel=Channel.CMCC,
|
|
179
|
+
template=Template.TXT,
|
|
180
|
+
))
|
|
181
|
+
|
|
171
182
|
# QQ 机器人:绑定 -> 认领群 -> 建配置 -> 发到群
|
|
172
183
|
from perk_pushplus import QqBotSaveRequest
|
|
173
184
|
link = client.qq_bot.get_bind_link() # link.url 生成二维码,或私聊发送 link.bindCode
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[pushplus(推送加)](https://www.pushplus.plus) 官方接口的 Python SDK,覆盖 **消息接口** 与 **全部开放接口**。
|
|
4
4
|
|
|
5
5
|
- **消息接口**(`/send`、`/batchSend`):单渠道 + 多渠道发送,含 Builder API。
|
|
6
|
-
- **开放接口**(`/api/open/...` 与 `/push/api/open/...`):用户、消息、消息 token、群组、群组用户、好友、webhook、渠道、ClawBot、QQ 机器人、功能设置、预处理信息、图片服务、push 表单、push 文档、push 表格、消息规则。
|
|
6
|
+
- **开放接口**(`/api/open/...` 与 `/push/api/open/...`):用户、消息、消息 token、群组、群组用户、好友、webhook、渠道、ClawBot、新消息 ClawBot、QQ 机器人、功能设置、预处理信息、图片服务、push 表单、push 文档、push 表格、消息规则。
|
|
7
7
|
- **AccessKey 自动管理**:缓存 + 过期前自动刷新;`code=401` 自动刷新并重试一次。
|
|
8
8
|
- **本地限流守卫**:命中 `code=900` 后按 token 短路同 token 后续发送,避免被服务端长期封禁。
|
|
9
9
|
- **回调解析**:`message_complate`、`add_topic_user`、`add_friend` 三类回调统一解析。
|
|
@@ -136,6 +136,17 @@ topic_blacklist = client.topic_user.blacklist_list(TopicUserListQuery.of(1, 20,
|
|
|
136
136
|
# webhook 渠道
|
|
137
137
|
webhooks = client.webhook.list()
|
|
138
138
|
|
|
139
|
+
# 新消息 ClawBot:绑定 Channel API Key 后,channel 传 cmcc(仅中国移动)
|
|
140
|
+
client.cmcc.bind("ak_xxxxxxxxxxxxxxxx")
|
|
141
|
+
cmcc_info = client.cmcc.info() # cmcc_info.bound == 1 表示已绑定
|
|
142
|
+
client.cmcc.send_test()
|
|
143
|
+
client.send(SendRequest(
|
|
144
|
+
title="服务告警",
|
|
145
|
+
content="订单服务响应超时",
|
|
146
|
+
channel=Channel.CMCC,
|
|
147
|
+
template=Template.TXT,
|
|
148
|
+
))
|
|
149
|
+
|
|
139
150
|
# QQ 机器人:绑定 -> 认领群 -> 建配置 -> 发到群
|
|
140
151
|
from perk_pushplus import QqBotSaveRequest
|
|
141
152
|
link = client.qq_bot.get_bind_link() # link.url 生成二维码,或私聊发送 link.bindCode
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "perk-pushplus-sdk"
|
|
7
|
-
version = "1.2.
|
|
7
|
+
version = "1.2.4"
|
|
8
8
|
description = "pushplus(推送加) 官方接口的 Python SDK,覆盖消息发送接口与全部开放接口。"
|
|
9
9
|
readme = { file = "README.md", content-type = "text/markdown" }
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -54,6 +54,8 @@ from .models import (
|
|
|
54
54
|
ClawBotInfo,
|
|
55
55
|
ClawBotMessage,
|
|
56
56
|
ClawBotQrCode,
|
|
57
|
+
CmccBindRequest,
|
|
58
|
+
CmccInfo,
|
|
57
59
|
CpItem,
|
|
58
60
|
DocContent,
|
|
59
61
|
DocListItem,
|
|
@@ -134,7 +136,7 @@ from .models import (
|
|
|
134
136
|
)
|
|
135
137
|
from .rate_limit import RateLimitGuard
|
|
136
138
|
|
|
137
|
-
__version__ = "1.2.
|
|
139
|
+
__version__ = "1.2.4"
|
|
138
140
|
|
|
139
141
|
__all__ = [
|
|
140
142
|
"__version__",
|
|
@@ -208,6 +210,8 @@ __all__ = [
|
|
|
208
210
|
"ClawBotQrCode",
|
|
209
211
|
"ClawBotInfo",
|
|
210
212
|
"ClawBotMessage",
|
|
213
|
+
"CmccBindRequest",
|
|
214
|
+
"CmccInfo",
|
|
211
215
|
"QqBotBindLink",
|
|
212
216
|
"QqBotInfo",
|
|
213
217
|
"QqBotBindInfo",
|
|
@@ -3,6 +3,7 @@ from .access_key import AccessKeyApi
|
|
|
3
3
|
from .base import AbstractApi, OpenAbstractApi
|
|
4
4
|
from .channel import ChannelApi
|
|
5
5
|
from .clawbot import ClawBotApi
|
|
6
|
+
from .cmcc import CmccApi
|
|
6
7
|
from .friend import FriendApi
|
|
7
8
|
from .image import ImageApi
|
|
8
9
|
from .form import FormApi
|
|
@@ -35,6 +36,7 @@ __all__ = [
|
|
|
35
36
|
"WebhookApi",
|
|
36
37
|
"ChannelApi",
|
|
37
38
|
"ClawBotApi",
|
|
39
|
+
"CmccApi",
|
|
38
40
|
"QqBotApi",
|
|
39
41
|
"SettingApi",
|
|
40
42
|
"PreApi",
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""开放接口 - 新消息 ClawBot(文档「九. 新消息ClawBot接口」)。
|
|
2
|
+
|
|
3
|
+
需先在手机 5G 消息的「新消息ClawBot」应用号中获取 Channel API Key,再调用绑定接口。
|
|
4
|
+
发送消息时 channel 传 ``cmcc``。仅支持中国移动用户。
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from ..models import CmccBindRequest, CmccInfo
|
|
9
|
+
from .base import OpenAbstractApi
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CmccApi(OpenAbstractApi):
|
|
13
|
+
"""新消息 ClawBot 渠道相关接口。"""
|
|
14
|
+
|
|
15
|
+
def bind(self, api_key: str) -> None:
|
|
16
|
+
"""绑定新消息 ClawBot。``api_key`` 必须以 ``ak_`` 或 ``app_`` 开头。"""
|
|
17
|
+
|
|
18
|
+
self.execute_open(
|
|
19
|
+
"POST", "/api/open/cmcc/bind", CmccBindRequest(apiKey=api_key), None
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
def info(self) -> CmccInfo:
|
|
23
|
+
"""查询绑定状态。"""
|
|
24
|
+
|
|
25
|
+
return self.execute_open("GET", "/api/open/cmcc/info", None, CmccInfo)
|
|
26
|
+
|
|
27
|
+
def unbind(self) -> None:
|
|
28
|
+
"""解绑新消息 ClawBot。"""
|
|
29
|
+
|
|
30
|
+
self.execute_open("GET", "/api/open/cmcc/unbind", None, None)
|
|
31
|
+
|
|
32
|
+
def send_test(self) -> None:
|
|
33
|
+
"""发送测试消息。未绑定会返回「未绑定新消息ClawBot」。"""
|
|
34
|
+
|
|
35
|
+
self.execute_open("GET", "/api/open/cmcc/test", None, None)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
__all__ = ["CmccApi"]
|
|
@@ -9,6 +9,7 @@ from .api import (
|
|
|
9
9
|
AccessKeyApi,
|
|
10
10
|
ChannelApi,
|
|
11
11
|
ClawBotApi,
|
|
12
|
+
CmccApi,
|
|
12
13
|
FriendApi,
|
|
13
14
|
ImageApi,
|
|
14
15
|
MessageApi,
|
|
@@ -79,6 +80,7 @@ class PushPlusClient:
|
|
|
79
80
|
self.webhook = WebhookApi(config, self.http_requester, self.access_key_manager)
|
|
80
81
|
self.channel = ChannelApi(config, self.http_requester, self.access_key_manager)
|
|
81
82
|
self.claw_bot = ClawBotApi(config, self.http_requester, self.access_key_manager)
|
|
83
|
+
self.cmcc = CmccApi(config, self.http_requester, self.access_key_manager)
|
|
82
84
|
self.qq_bot = QqBotApi(config, self.http_requester, self.access_key_manager)
|
|
83
85
|
self.setting = SettingApi(config, self.http_requester, self.access_key_manager)
|
|
84
86
|
self.pre = PreApi(config, self.http_requester, self.access_key_manager)
|
|
@@ -36,6 +36,7 @@ from .open_friend import FriendBlacklistItem, FriendItem, FriendQrCode
|
|
|
36
36
|
from .open_webhook import WebhookItem, WebhookSaveRequest
|
|
37
37
|
from .open_channel import CpItem, MailDetail, MailItem, MpItem
|
|
38
38
|
from .open_clawbot import ClawBotInfo, ClawBotMessage, ClawBotQrCode
|
|
39
|
+
from .open_cmcc import CmccBindRequest, CmccInfo
|
|
39
40
|
from .open_qqbot import (
|
|
40
41
|
QqBotBindInfo,
|
|
41
42
|
QqBotBindLink,
|
|
@@ -120,6 +121,8 @@ __all__ = [
|
|
|
120
121
|
"ClawBotQrCode",
|
|
121
122
|
"ClawBotInfo",
|
|
122
123
|
"ClawBotMessage",
|
|
124
|
+
"CmccBindRequest",
|
|
125
|
+
"CmccInfo",
|
|
123
126
|
"QqBotBindLink",
|
|
124
127
|
"QqBotInfo",
|
|
125
128
|
"QqBotBindInfo",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""开放接口 - 新消息 ClawBot 模型。"""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class CmccBindRequest:
|
|
10
|
+
"""新消息 ClawBot 绑定请求。"""
|
|
11
|
+
|
|
12
|
+
apiKey: str
|
|
13
|
+
"""中国移动新消息 Channel API Key,必须以 ak_ 或 app_ 开头。"""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class CmccInfo:
|
|
18
|
+
"""新消息 ClawBot 绑定状态。"""
|
|
19
|
+
|
|
20
|
+
bound: Optional[int] = None
|
|
21
|
+
"""是否已绑定;0-未绑定,1-已绑定。"""
|
|
22
|
+
apiKeyMasked: Optional[str] = None
|
|
23
|
+
"""脱敏后的 API Key。"""
|
|
24
|
+
createTime: Optional[str] = None
|
|
25
|
+
"""绑定时间。"""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
__all__ = ["CmccBindRequest", "CmccInfo"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: perk-pushplus-sdk
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.4
|
|
4
4
|
Summary: pushplus(推送加) 官方接口的 Python SDK,覆盖消息发送接口与全部开放接口。
|
|
5
5
|
Author: perk-net
|
|
6
6
|
License: Apache-2.0
|
|
@@ -35,7 +35,7 @@ Requires-Dist: responses>=0.23; extra == "dev"
|
|
|
35
35
|
[pushplus(推送加)](https://www.pushplus.plus) 官方接口的 Python SDK,覆盖 **消息接口** 与 **全部开放接口**。
|
|
36
36
|
|
|
37
37
|
- **消息接口**(`/send`、`/batchSend`):单渠道 + 多渠道发送,含 Builder API。
|
|
38
|
-
- **开放接口**(`/api/open/...` 与 `/push/api/open/...`):用户、消息、消息 token、群组、群组用户、好友、webhook、渠道、ClawBot、QQ 机器人、功能设置、预处理信息、图片服务、push 表单、push 文档、push 表格、消息规则。
|
|
38
|
+
- **开放接口**(`/api/open/...` 与 `/push/api/open/...`):用户、消息、消息 token、群组、群组用户、好友、webhook、渠道、ClawBot、新消息 ClawBot、QQ 机器人、功能设置、预处理信息、图片服务、push 表单、push 文档、push 表格、消息规则。
|
|
39
39
|
- **AccessKey 自动管理**:缓存 + 过期前自动刷新;`code=401` 自动刷新并重试一次。
|
|
40
40
|
- **本地限流守卫**:命中 `code=900` 后按 token 短路同 token 后续发送,避免被服务端长期封禁。
|
|
41
41
|
- **回调解析**:`message_complate`、`add_topic_user`、`add_friend` 三类回调统一解析。
|
|
@@ -168,6 +168,17 @@ topic_blacklist = client.topic_user.blacklist_list(TopicUserListQuery.of(1, 20,
|
|
|
168
168
|
# webhook 渠道
|
|
169
169
|
webhooks = client.webhook.list()
|
|
170
170
|
|
|
171
|
+
# 新消息 ClawBot:绑定 Channel API Key 后,channel 传 cmcc(仅中国移动)
|
|
172
|
+
client.cmcc.bind("ak_xxxxxxxxxxxxxxxx")
|
|
173
|
+
cmcc_info = client.cmcc.info() # cmcc_info.bound == 1 表示已绑定
|
|
174
|
+
client.cmcc.send_test()
|
|
175
|
+
client.send(SendRequest(
|
|
176
|
+
title="服务告警",
|
|
177
|
+
content="订单服务响应超时",
|
|
178
|
+
channel=Channel.CMCC,
|
|
179
|
+
template=Template.TXT,
|
|
180
|
+
))
|
|
181
|
+
|
|
171
182
|
# QQ 机器人:绑定 -> 认领群 -> 建配置 -> 发到群
|
|
172
183
|
from perk_pushplus import QqBotSaveRequest
|
|
173
184
|
link = client.qq_bot.get_bind_link() # link.url 生成二维码,或私聊发送 link.bindCode
|
{perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus_sdk.egg-info/SOURCES.txt
RENAMED
|
@@ -16,6 +16,7 @@ src/perk_pushplus/api/access_key.py
|
|
|
16
16
|
src/perk_pushplus/api/base.py
|
|
17
17
|
src/perk_pushplus/api/channel.py
|
|
18
18
|
src/perk_pushplus/api/clawbot.py
|
|
19
|
+
src/perk_pushplus/api/cmcc.py
|
|
19
20
|
src/perk_pushplus/api/doc.py
|
|
20
21
|
src/perk_pushplus/api/excel.py
|
|
21
22
|
src/perk_pushplus/api/form.py
|
|
@@ -39,6 +40,7 @@ src/perk_pushplus/models/callback.py
|
|
|
39
40
|
src/perk_pushplus/models/open_access.py
|
|
40
41
|
src/perk_pushplus/models/open_channel.py
|
|
41
42
|
src/perk_pushplus/models/open_clawbot.py
|
|
43
|
+
src/perk_pushplus/models/open_cmcc.py
|
|
42
44
|
src/perk_pushplus/models/open_doc.py
|
|
43
45
|
src/perk_pushplus/models/open_form.py
|
|
44
46
|
src/perk_pushplus/models/open_forward.py
|
|
@@ -18,6 +18,7 @@ from perk_pushplus import (
|
|
|
18
18
|
def test_channel_of_case_insensitive():
|
|
19
19
|
assert Channel.of("WeChat") is Channel.WECHAT
|
|
20
20
|
assert Channel.of("clawbot") is Channel.CLAWBOT
|
|
21
|
+
assert Channel.of("cmcc") is Channel.CMCC
|
|
21
22
|
assert Channel.of(None) is None
|
|
22
23
|
assert Channel.of("not-exist") is None
|
|
23
24
|
|
|
@@ -358,6 +358,34 @@ def test_excel_import():
|
|
|
358
358
|
assert imported.docCode == "Sh3xY7kP"
|
|
359
359
|
|
|
360
360
|
|
|
361
|
+
def test_cmcc_bind_and_status():
|
|
362
|
+
req = ScriptedRequester()
|
|
363
|
+
req.push("/api/open/cmcc/bind", 200, _ok(None))
|
|
364
|
+
req.push(
|
|
365
|
+
"/api/open/cmcc/info",
|
|
366
|
+
200,
|
|
367
|
+
_ok({"bound": 1, "apiKeyMasked": "ak_***xxx", "createTime": "2026-09-14 10:20:00"}),
|
|
368
|
+
)
|
|
369
|
+
req.push("/api/open/cmcc/test", 200, _ok(None))
|
|
370
|
+
req.push("/api/open/cmcc/unbind", 200, _ok(None))
|
|
371
|
+
client = _build_client(req)
|
|
372
|
+
|
|
373
|
+
client.cmcc.bind("ak_xxxxxxxxxxxxxxxx")
|
|
374
|
+
bind_call = next(c for c in req.calls if "/api/open/cmcc/bind" in c[1])
|
|
375
|
+
assert bind_call[2]["access-key"] == "ak-1"
|
|
376
|
+
assert json.loads(bind_call[3])["apiKey"] == "ak_xxxxxxxxxxxxxxxx"
|
|
377
|
+
|
|
378
|
+
info = client.cmcc.info()
|
|
379
|
+
assert info.bound == 1
|
|
380
|
+
assert info.apiKeyMasked == "ak_***xxx"
|
|
381
|
+
|
|
382
|
+
client.cmcc.send_test()
|
|
383
|
+
assert any("/api/open/cmcc/test" in c[1] for c in req.calls)
|
|
384
|
+
|
|
385
|
+
client.cmcc.unbind()
|
|
386
|
+
assert any("/api/open/cmcc/unbind" in c[1] for c in req.calls)
|
|
387
|
+
|
|
388
|
+
|
|
361
389
|
def test_qq_bot_bind_and_group_config():
|
|
362
390
|
req = ScriptedRequester()
|
|
363
391
|
req.push(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_channel.py
RENAMED
|
File without changes
|
{perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_clawbot.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_forward.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_message.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_setting.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus/models/open_webhook.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus_sdk.egg-info/requires.txt
RENAMED
|
File without changes
|
{perk_pushplus_sdk-1.2.3 → perk_pushplus_sdk-1.2.4}/src/perk_pushplus_sdk.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|