Skip to content

Commit 8abb4a3

Browse files
committed
新增PushBullet, SimplePush, AnPush推送平台
1 parent 651f4fe commit 8abb4a3

17 files changed

+1120
-5
lines changed

.github/workflows/api-test.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: Api Test
22
on:
33
schedule:
44
- cron: '36 11 * * 6'
5-
env:
6-
version: 3.1.2
75
jobs:
86
test:
97
runs-on: ubuntu-latest

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
- [Ntfy](https://docs.ntfy.sh/publish/) -- Ntfy
3939
- [一封传话](https://www.phprm.com/push/h5/) -- YiFengChuanHua
4040
- [WPush](https://wpush.cn/) -- WPush
41+
- [PushBullet](https://www.pushbullet.com/) -- PushBullet
42+
- [SimplePush](https://simplepush.io/) -- SimplePush
43+
- [AnPush](https://anpush.com/) -- AnPush
4144

4245
## 安装
4346

@@ -328,6 +331,31 @@ const { PushApi } = require('all-pusher-api'); // 多平台同时推送
328331
token: '******'
329332
}
330333
}
334+
},
335+
{
336+
name: 'PushBullet',
337+
config: {
338+
key: {
339+
token: '******'
340+
}
341+
}
342+
},
343+
{
344+
name: 'SimplePush',
345+
config: {
346+
key: {
347+
token: '******'
348+
}
349+
}
350+
},
351+
{
352+
name: 'AnPush',
353+
config: {
354+
key: {
355+
token: '******',
356+
channel: '******'
357+
}
358+
}
331359
}
332360
])
333361
.send({ message: '测试文本' })).map((e) => (e.result.status >= 200 && e.result.status < 300) ? `${e.name} 测试成功` : e));
@@ -607,16 +635,19 @@ const results: Array<{
607635
- Showdoc: 'text'
608636
- Pushover: 'text'
609637
- 爱语飞飞: 'text'
638+
- SimplePush: 'text'
610639
- QQ(go-cqhttp): 'text', 'other'
611640
- ~~Qmsg: 'text', 'other'~~
612641
- Discord: 'text', 'other'
613642
- 飞书: 'text', 'other'
643+
- PushBullet: 'text', 'other'
614644
- ~~NowPush: 'text', 'other'~~
615645
- Chanify: 'text', 'other'
616646
- Bark: 'text', 'other'
617647
- Server酱Turbo: 'text', 'markdown'
618648
- 息知: 'text', 'markdown'
619649
- WPush: 'text', 'markdown'
650+
- AnPush: 'text', 'markdown'
620651
- PushDeer: 'text', 'markdown', 'other'
621652
- QQ频道: 'text', 'markdown', 'other'
622653
- 企业微信: 'text', 'markdown', 'other'

config/template.yaml.js

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,3 +1279,125 @@ const { WPush } = require("../dist/WPush")
12791279
password:
12801280
name: 代理密码
12811281
type: text
1282+
- name: PushBullet
1283+
type: json
1284+
filename: copy
1285+
quote: PushBullet配置参数生成器
1286+
author: HCLonely
1287+
body:
1288+
key:
1289+
name: 认证信息
1290+
type: object
1291+
body:
1292+
token:
1293+
name: Token
1294+
desp: Token
1295+
type: text
1296+
required: true
1297+
proxy:
1298+
name: 代理设置(可选)
1299+
type: object
1300+
body:
1301+
enable:
1302+
name: 启用
1303+
type: boolean
1304+
defaultValue: false
1305+
protocol:
1306+
name: 代理协议
1307+
type: text
1308+
defaultValue: http
1309+
host:
1310+
name: 代理主机地址
1311+
type: text
1312+
port:
1313+
name: 代理端口
1314+
type: text
1315+
username:
1316+
name: 代理用户名
1317+
type: text
1318+
password:
1319+
name: 代理密码
1320+
type: text
1321+
- name: SimplePush
1322+
type: json
1323+
filename: copy
1324+
quote: SimplePush配置参数生成器
1325+
author: HCLonely
1326+
body:
1327+
key:
1328+
name: 认证信息
1329+
type: object
1330+
body:
1331+
token:
1332+
name: Token
1333+
desp: Token
1334+
type: text
1335+
required: true
1336+
proxy:
1337+
name: 代理设置(可选)
1338+
type: object
1339+
body:
1340+
enable:
1341+
name: 启用
1342+
type: boolean
1343+
defaultValue: false
1344+
protocol:
1345+
name: 代理协议
1346+
type: text
1347+
defaultValue: http
1348+
host:
1349+
name: 代理主机地址
1350+
type: text
1351+
port:
1352+
name: 代理端口
1353+
type: text
1354+
username:
1355+
name: 代理用户名
1356+
type: text
1357+
password:
1358+
name: 代理密码
1359+
type: text
1360+
- name: AnPush
1361+
type: json
1362+
filename: copy
1363+
quote: AnPush配置参数生成器
1364+
author: HCLonely
1365+
body:
1366+
key:
1367+
name: 认证信息
1368+
type: object
1369+
body:
1370+
token:
1371+
name: Token
1372+
desp: Token
1373+
type: text
1374+
required: true
1375+
channel:
1376+
name: channel
1377+
desp: 推送通道id
1378+
type: text
1379+
required: true
1380+
proxy:
1381+
name: 代理设置(可选)
1382+
type: object
1383+
body:
1384+
enable:
1385+
name: 启用
1386+
type: boolean
1387+
defaultValue: false
1388+
protocol:
1389+
name: 代理协议
1390+
type: text
1391+
defaultValue: http
1392+
host:
1393+
name: 代理主机地址
1394+
type: text
1395+
port:
1396+
name: 代理端口
1397+
type: text
1398+
username:
1399+
name: 代理用户名
1400+
type: text
1401+
password:
1402+
name: 代理密码
1403+
type: text

dist/AnPush.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
'use strict';
2+
3+
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
4+
var axios = require('axios');
5+
var tool = require('./tool');
6+
class AnPush {
7+
constructor({
8+
token,
9+
key,
10+
channel,
11+
proxy
12+
}) {
13+
_defineProperty(this, "_KEY", void 0);
14+
_defineProperty(this, "baseURL", 'https://api.anpush.com/push/');
15+
_defineProperty(this, "httpsAgent", void 0);
16+
_defineProperty(this, "channel", void 0);
17+
const $key = {
18+
token,
19+
channel,
20+
...key
21+
};
22+
if (!$key.token) {
23+
throw new Error('Missing Parameter: token');
24+
}
25+
if ($key.channel) {
26+
this.channel = $key.channel;
27+
}
28+
this._KEY = $key.token;
29+
if (proxy && proxy.enable) {
30+
this.httpsAgent = tool.proxy2httpsAgent(proxy);
31+
}
32+
}
33+
async send(sendOptions) {
34+
if (!sendOptions.message && !sendOptions.customOptions) {
35+
return {
36+
status: 0,
37+
statusText: 'Missing Parameter: message',
38+
extraMessage: null
39+
};
40+
}
41+
let anPushOptions;
42+
if (sendOptions.customOptions) {
43+
anPushOptions = sendOptions.customOptions;
44+
} else {
45+
anPushOptions = {
46+
channel: this.channel,
47+
content: sendOptions.message,
48+
title: sendOptions.title || sendOptions.message.split('\n')[0].trim().slice(0, 10)
49+
};
50+
}
51+
if (sendOptions.extraOptions) {
52+
anPushOptions = {
53+
...anPushOptions,
54+
...sendOptions.extraOptions
55+
};
56+
}
57+
const axiosOptions = {
58+
url: `${this.baseURL}${this._KEY}`,
59+
method: 'POST',
60+
headers: {
61+
'Content-type': 'application/x-www-form-urlencoded'
62+
},
63+
data: anPushOptions
64+
};
65+
if (this.httpsAgent) {
66+
axiosOptions.httpsAgent = this.httpsAgent;
67+
}
68+
return axios(axiosOptions).then(response => {
69+
if (response.data) {
70+
if (response.data.code === 200) {
71+
return {
72+
status: 200,
73+
statusText: 'Success',
74+
extraMessage: response
75+
};
76+
}
77+
return {
78+
status: 100,
79+
statusText: 'Error',
80+
extraMessage: response
81+
};
82+
}
83+
return {
84+
status: 101,
85+
statusText: 'No Response Data',
86+
extraMessage: response
87+
};
88+
}).catch(error => ({
89+
status: 102,
90+
statusText: 'Request Error',
91+
extraMessage: error
92+
}));
93+
}
94+
}
95+
exports.AnPush = AnPush;

dist/PushBullet.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
'use strict';
2+
3+
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
4+
var axios = require('axios');
5+
var tool = require('./tool');
6+
class PushBullet {
7+
constructor({
8+
token,
9+
key,
10+
proxy
11+
}) {
12+
_defineProperty(this, "_KEY", void 0);
13+
_defineProperty(this, "baseURL", 'https://api.pushbullet.com/v2/pushes');
14+
_defineProperty(this, "httpsAgent", void 0);
15+
const $key = {
16+
token,
17+
...key
18+
};
19+
if (!$key.token) {
20+
throw new Error('Missing Parameter: token');
21+
}
22+
this._KEY = $key.token;
23+
if (proxy && proxy.enable) {
24+
this.httpsAgent = tool.proxy2httpsAgent(proxy);
25+
}
26+
}
27+
async send(sendOptions) {
28+
if (!sendOptions.message && !sendOptions.customOptions) {
29+
return {
30+
status: 0,
31+
statusText: 'Missing Parameter: message',
32+
extraMessage: null
33+
};
34+
}
35+
let pushBulletOptions;
36+
if (sendOptions.customOptions) {
37+
pushBulletOptions = sendOptions.customOptions;
38+
} else {
39+
pushBulletOptions = {
40+
type: 'note',
41+
body: sendOptions.message,
42+
title: sendOptions.title || sendOptions.message.split('\n')[0].trim().slice(0, 10)
43+
};
44+
}
45+
if (sendOptions.extraOptions) {
46+
pushBulletOptions = {
47+
...pushBulletOptions,
48+
...sendOptions.extraOptions
49+
};
50+
}
51+
const axiosOptions = {
52+
url: this.baseURL,
53+
method: 'POST',
54+
headers: {
55+
'Access-Token': this._KEY,
56+
'Content-type': 'application/json'
57+
},
58+
data: pushBulletOptions
59+
};
60+
if (this.httpsAgent) {
61+
axiosOptions.httpsAgent = this.httpsAgent;
62+
}
63+
return axios(axiosOptions).then(response => {
64+
if (response.data) {
65+
if (response.status === 200) {
66+
return {
67+
status: 200,
68+
statusText: 'Success',
69+
extraMessage: response
70+
};
71+
}
72+
return {
73+
status: 100,
74+
statusText: 'Error',
75+
extraMessage: response
76+
};
77+
}
78+
return {
79+
status: 101,
80+
statusText: 'No Response Data',
81+
extraMessage: response
82+
};
83+
}).catch(error => ({
84+
status: 102,
85+
statusText: 'Request Error',
86+
extraMessage: error
87+
}));
88+
}
89+
}
90+
exports.PushBullet = PushBullet;

0 commit comments

Comments
 (0)