@perk-net/perk-pushplus-sdk 1.2.1 → 1.2.2
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.
- package/README.md +14 -1
- package/dist/index.cjs +52 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +97 -2
- package/dist/index.d.ts +97 -2
- package/dist/index.global.js +52 -0
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +52 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/qqbot-api.ts +75 -0
- package/src/client.ts +3 -0
- package/src/enums.ts +2 -0
- package/src/index.ts +7 -0
- package/src/models.ts +77 -0
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
- **同时支持 Node.js 与浏览器**:Node.js 18+ 使用内置 `fetch`,浏览器使用原生 `fetch`,无运行时依赖。
|
|
6
6
|
- **三种产物**:CommonJS (`.cjs`) + ESModule (`.js`) + 浏览器 IIFE (`.global.js`),可通过 npm / `<script>` 直接加载。
|
|
7
7
|
- **完整 TypeScript 类型**:所有请求 / 响应 / 枚举 / 回调全部带类型声明。
|
|
8
|
-
- **全部开放接口**:用户、消息、消息 token、群组、群组用户、好友、webhook、渠道、ClawBot
|
|
8
|
+
- **全部开放接口**:用户、消息、消息 token、群组、群组用户、好友、webhook、渠道、ClawBot、QQ 机器人、功能设置、预处理、图片服务(含一键上传到 PushPlus 图床)、push 表单、push 文档、push 表格。
|
|
9
9
|
- **AccessKey 自动管理**:缓存 + 过期前自动刷新;`code=401` 自动刷新并重试一次。
|
|
10
10
|
- **本地限流守卫**:命中 `code=900` 后按 token 短路同 token 后续发送,避免被服务端长期封禁。
|
|
11
11
|
- **Builder 链式 API**:与 Java/Python SDK 风格保持一致。
|
|
@@ -195,6 +195,19 @@ const mps = await client.channel.mpList();
|
|
|
195
195
|
// ClawBot
|
|
196
196
|
const botQr = await client.clawBot.getBotQrcode();
|
|
197
197
|
|
|
198
|
+
// QQ 机器人:绑定 -> 认领群 -> 建配置 -> 发到群
|
|
199
|
+
const link = await client.qqBot.getBindLink(); // link.url 生成二维码,或私聊发送 link.bindCode
|
|
200
|
+
const bind = await client.qqBot.botInfo(); // bind.isBind === 1 表示已绑定
|
|
201
|
+
const qqGroups = await client.qqBot.groupList();
|
|
202
|
+
await client.qqBot.add({ qqName: '运维告警群', qqCode: 'ops-group', qqGroupId: qqGroups[0].id });
|
|
203
|
+
await client.send({
|
|
204
|
+
title: '服务告警',
|
|
205
|
+
content: '订单服务响应超时',
|
|
206
|
+
channel: Channel.QQ,
|
|
207
|
+
option: 'ops-group', // 不传 option 则发给自己
|
|
208
|
+
template: Template.TXT,
|
|
209
|
+
});
|
|
210
|
+
|
|
198
211
|
// 设置
|
|
199
212
|
await client.setting.changeIsSend(1); // 启用发送
|
|
200
213
|
await client.setting.changeOpenMessageType(0);
|
package/dist/index.cjs
CHANGED
|
@@ -11,6 +11,7 @@ var Channel = /* @__PURE__ */ ((Channel2) => {
|
|
|
11
11
|
Channel2["EXTENSION"] = "extension";
|
|
12
12
|
Channel2["APP"] = "app";
|
|
13
13
|
Channel2["CLAWBOT"] = "clawbot";
|
|
14
|
+
Channel2["QQ"] = "qq";
|
|
14
15
|
return Channel2;
|
|
15
16
|
})(Channel || {});
|
|
16
17
|
var Template = /* @__PURE__ */ ((Template2) => {
|
|
@@ -1326,6 +1327,55 @@ var PreApi = class extends OpenAbstractApi {
|
|
|
1326
1327
|
}
|
|
1327
1328
|
};
|
|
1328
1329
|
|
|
1330
|
+
// src/api/qqbot-api.ts
|
|
1331
|
+
var SEND_TYPE_QQ_GROUP = 2;
|
|
1332
|
+
var QqBotApi = class extends OpenAbstractApi {
|
|
1333
|
+
constructor(config, http, mgr) {
|
|
1334
|
+
super(config, http, mgr);
|
|
1335
|
+
}
|
|
1336
|
+
/** 1. 获取绑定链接与绑定码;refresh 为 true 时旧绑定码失效并重新生成。 */
|
|
1337
|
+
getBindLink(refresh = false) {
|
|
1338
|
+
const path = refresh ? this.appendQuery("/api/open/qqBot/getBindLink", { refresh: true }) : "/api/open/qqBot/getBindLink";
|
|
1339
|
+
return this.executeOpen("GET", path);
|
|
1340
|
+
}
|
|
1341
|
+
/** 2. 查询绑定状态。 */
|
|
1342
|
+
botInfo() {
|
|
1343
|
+
return this.executeOpen("GET", "/api/open/qqBot/botInfo");
|
|
1344
|
+
}
|
|
1345
|
+
/** 3. 解绑 QQ 机器人。 */
|
|
1346
|
+
async unbind() {
|
|
1347
|
+
await this.executeOpen("GET", "/api/open/qqBot/unbind");
|
|
1348
|
+
}
|
|
1349
|
+
/** 4. 获取机器人已加入的 QQ 群列表。 */
|
|
1350
|
+
async groupList() {
|
|
1351
|
+
var _a;
|
|
1352
|
+
return (_a = await this.executeOpen("GET", "/api/open/qqBot/groupList")) != null ? _a : [];
|
|
1353
|
+
}
|
|
1354
|
+
/** 5. 获取 QQ 机器人渠道配置列表。 */
|
|
1355
|
+
list(q) {
|
|
1356
|
+
return this.executeOpen("POST", "/api/open/qqBot/list", q != null ? q : {});
|
|
1357
|
+
}
|
|
1358
|
+
/** 6. 新增渠道配置,用于把消息发送到指定 QQ 群;发给自己无需创建配置。 */
|
|
1359
|
+
async add(req) {
|
|
1360
|
+
await this.executeOpen("POST", "/api/open/qqBot/add", withDefaultSendType(req));
|
|
1361
|
+
}
|
|
1362
|
+
/** 7. 修改渠道配置;配置编码不可修改。 */
|
|
1363
|
+
async edit(req) {
|
|
1364
|
+
await this.executeOpen("POST", "/api/open/qqBot/edit", withDefaultSendType(req));
|
|
1365
|
+
}
|
|
1366
|
+
/** 8. 删除渠道配置。 */
|
|
1367
|
+
async delete(id) {
|
|
1368
|
+
await this.executeOpen(
|
|
1369
|
+
"DELETE",
|
|
1370
|
+
this.appendQuery("/api/open/qqBot/delete", { id })
|
|
1371
|
+
);
|
|
1372
|
+
}
|
|
1373
|
+
};
|
|
1374
|
+
function withDefaultSendType(req) {
|
|
1375
|
+
var _a;
|
|
1376
|
+
return { ...req, sendType: (_a = req.sendType) != null ? _a : SEND_TYPE_QQ_GROUP };
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1329
1379
|
// src/api/setting-api.ts
|
|
1330
1380
|
var SettingApi = class extends OpenAbstractApi {
|
|
1331
1381
|
constructor(config, http, mgr) {
|
|
@@ -1669,6 +1719,7 @@ var PushPlusClient = class _PushPlusClient {
|
|
|
1669
1719
|
this.webhook = new WebhookApi(this.config, this.httpRequester, this.accessKeyManager);
|
|
1670
1720
|
this.channel = new ChannelApi(this.config, this.httpRequester, this.accessKeyManager);
|
|
1671
1721
|
this.clawBot = new ClawBotApi(this.config, this.httpRequester, this.accessKeyManager);
|
|
1722
|
+
this.qqBot = new QqBotApi(this.config, this.httpRequester, this.accessKeyManager);
|
|
1672
1723
|
this.setting = new SettingApi(this.config, this.httpRequester, this.accessKeyManager);
|
|
1673
1724
|
this.pre = new PreApi(this.config, this.httpRequester, this.accessKeyManager);
|
|
1674
1725
|
this.image = new ImageApi(this.config, this.httpRequester, this.accessKeyManager);
|
|
@@ -1936,6 +1987,7 @@ exports.PushPlusClient = PushPlusClient;
|
|
|
1936
1987
|
exports.PushPlusClientBuilder = PushPlusClientBuilder;
|
|
1937
1988
|
exports.PushPlusError = PushPlusError;
|
|
1938
1989
|
exports.PushPlusException = PushPlusException;
|
|
1990
|
+
exports.QqBotApi = QqBotApi;
|
|
1939
1991
|
exports.RateLimitGuard = RateLimitGuard;
|
|
1940
1992
|
exports.SendRequestBuilder = SendRequestBuilder;
|
|
1941
1993
|
exports.SendStatus = SendStatus;
|