Skip to content

Commit

Permalink
新增PushBullet, SimplePush, AnPush推送平台
Browse files Browse the repository at this point in the history
  • Loading branch information
HCLonely committed May 13, 2024
1 parent 651f4fe commit 8abb4a3
Show file tree
Hide file tree
Showing 17 changed files with 1,120 additions and 5 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/api-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: Api Test
on:
schedule:
- cron: '36 11 * * 6'
env:
version: 3.1.2
jobs:
test:
runs-on: ubuntu-latest
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
- [Ntfy](https://docs.ntfy.sh/publish/) -- Ntfy
- [一封传话](https://www.phprm.com/push/h5/) -- YiFengChuanHua
- [WPush](https://wpush.cn/) -- WPush
- [PushBullet](https://www.pushbullet.com/) -- PushBullet
- [SimplePush](https://simplepush.io/) -- SimplePush
- [AnPush](https://anpush.com/) -- AnPush

## 安装

Expand Down Expand Up @@ -328,6 +331,31 @@ const { PushApi } = require('all-pusher-api'); // 多平台同时推送
token: '******'
}
}
},
{
name: 'PushBullet',
config: {
key: {
token: '******'
}
}
},
{
name: 'SimplePush',
config: {
key: {
token: '******'
}
}
},
{
name: 'AnPush',
config: {
key: {
token: '******',
channel: '******'
}
}
}
])
.send({ message: '测试文本' })).map((e) => (e.result.status >= 200 && e.result.status < 300) ? `${e.name} 测试成功` : e));
Expand Down Expand Up @@ -607,16 +635,19 @@ const results: Array<{
- Showdoc: 'text'
- Pushover: 'text'
- 爱语飞飞: 'text'
- SimplePush: 'text'
- QQ(go-cqhttp): 'text', 'other'
- ~~Qmsg: 'text', 'other'~~
- Discord: 'text', 'other'
- 飞书: 'text', 'other'
- PushBullet: 'text', 'other'
- ~~NowPush: 'text', 'other'~~
- Chanify: 'text', 'other'
- Bark: 'text', 'other'
- Server酱Turbo: 'text', 'markdown'
- 息知: 'text', 'markdown'
- WPush: 'text', 'markdown'
- AnPush: 'text', 'markdown'
- PushDeer: 'text', 'markdown', 'other'
- QQ频道: 'text', 'markdown', 'other'
- 企业微信: 'text', 'markdown', 'other'
Expand Down
122 changes: 122 additions & 0 deletions config/template.yaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -1279,3 +1279,125 @@ const { WPush } = require("../dist/WPush")
password:
name: 代理密码
type: text
- name: PushBullet
type: json
filename: copy
quote: PushBullet配置参数生成器
author: HCLonely
body:
key:
name: 认证信息
type: object
body:
token:
name: Token
desp: Token
type: text
required: true
proxy:
name: 代理设置(可选)
type: object
body:
enable:
name: 启用
type: boolean
defaultValue: false
protocol:
name: 代理协议
type: text
defaultValue: http
host:
name: 代理主机地址
type: text
port:
name: 代理端口
type: text
username:
name: 代理用户名
type: text
password:
name: 代理密码
type: text
- name: SimplePush
type: json
filename: copy
quote: SimplePush配置参数生成器
author: HCLonely
body:
key:
name: 认证信息
type: object
body:
token:
name: Token
desp: Token
type: text
required: true
proxy:
name: 代理设置(可选)
type: object
body:
enable:
name: 启用
type: boolean
defaultValue: false
protocol:
name: 代理协议
type: text
defaultValue: http
host:
name: 代理主机地址
type: text
port:
name: 代理端口
type: text
username:
name: 代理用户名
type: text
password:
name: 代理密码
type: text
- name: AnPush
type: json
filename: copy
quote: AnPush配置参数生成器
author: HCLonely
body:
key:
name: 认证信息
type: object
body:
token:
name: Token
desp: Token
type: text
required: true
channel:
name: channel
desp: 推送通道id
type: text
required: true
proxy:
name: 代理设置(可选)
type: object
body:
enable:
name: 启用
type: boolean
defaultValue: false
protocol:
name: 代理协议
type: text
defaultValue: http
host:
name: 代理主机地址
type: text
port:
name: 代理端口
type: text
username:
name: 代理用户名
type: text
password:
name: 代理密码
type: text
95 changes: 95 additions & 0 deletions dist/AnPush.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
'use strict';

var _defineProperty = require("@babel/runtime/helpers/defineProperty");
var axios = require('axios');
var tool = require('./tool');
class AnPush {
constructor({
token,
key,
channel,
proxy
}) {
_defineProperty(this, "_KEY", void 0);
_defineProperty(this, "baseURL", 'https://api.anpush.com/push/');
_defineProperty(this, "httpsAgent", void 0);
_defineProperty(this, "channel", void 0);
const $key = {
token,
channel,
...key
};
if (!$key.token) {
throw new Error('Missing Parameter: token');
}
if ($key.channel) {
this.channel = $key.channel;
}
this._KEY = $key.token;
if (proxy && proxy.enable) {
this.httpsAgent = tool.proxy2httpsAgent(proxy);
}
}
async send(sendOptions) {
if (!sendOptions.message && !sendOptions.customOptions) {
return {
status: 0,
statusText: 'Missing Parameter: message',
extraMessage: null
};
}
let anPushOptions;
if (sendOptions.customOptions) {
anPushOptions = sendOptions.customOptions;
} else {
anPushOptions = {
channel: this.channel,
content: sendOptions.message,
title: sendOptions.title || sendOptions.message.split('\n')[0].trim().slice(0, 10)
};
}
if (sendOptions.extraOptions) {
anPushOptions = {
...anPushOptions,
...sendOptions.extraOptions
};
}
const axiosOptions = {
url: `${this.baseURL}${this._KEY}`,
method: 'POST',
headers: {
'Content-type': 'application/x-www-form-urlencoded'
},
data: anPushOptions
};
if (this.httpsAgent) {
axiosOptions.httpsAgent = this.httpsAgent;
}
return axios(axiosOptions).then(response => {
if (response.data) {
if (response.data.code === 200) {
return {
status: 200,
statusText: 'Success',
extraMessage: response
};
}
return {
status: 100,
statusText: 'Error',
extraMessage: response
};
}
return {
status: 101,
statusText: 'No Response Data',
extraMessage: response
};
}).catch(error => ({
status: 102,
statusText: 'Request Error',
extraMessage: error
}));
}
}
exports.AnPush = AnPush;
90 changes: 90 additions & 0 deletions dist/PushBullet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
'use strict';

var _defineProperty = require("@babel/runtime/helpers/defineProperty");
var axios = require('axios');
var tool = require('./tool');
class PushBullet {
constructor({
token,
key,
proxy
}) {
_defineProperty(this, "_KEY", void 0);
_defineProperty(this, "baseURL", 'https://api.pushbullet.com/v2/pushes');
_defineProperty(this, "httpsAgent", void 0);
const $key = {
token,
...key
};
if (!$key.token) {
throw new Error('Missing Parameter: token');
}
this._KEY = $key.token;
if (proxy && proxy.enable) {
this.httpsAgent = tool.proxy2httpsAgent(proxy);
}
}
async send(sendOptions) {
if (!sendOptions.message && !sendOptions.customOptions) {
return {
status: 0,
statusText: 'Missing Parameter: message',
extraMessage: null
};
}
let pushBulletOptions;
if (sendOptions.customOptions) {
pushBulletOptions = sendOptions.customOptions;
} else {
pushBulletOptions = {
type: 'note',
body: sendOptions.message,
title: sendOptions.title || sendOptions.message.split('\n')[0].trim().slice(0, 10)
};
}
if (sendOptions.extraOptions) {
pushBulletOptions = {
...pushBulletOptions,
...sendOptions.extraOptions
};
}
const axiosOptions = {
url: this.baseURL,
method: 'POST',
headers: {
'Access-Token': this._KEY,
'Content-type': 'application/json'
},
data: pushBulletOptions
};
if (this.httpsAgent) {
axiosOptions.httpsAgent = this.httpsAgent;
}
return axios(axiosOptions).then(response => {
if (response.data) {
if (response.status === 200) {
return {
status: 200,
statusText: 'Success',
extraMessage: response
};
}
return {
status: 100,
statusText: 'Error',
extraMessage: response
};
}
return {
status: 101,
statusText: 'No Response Data',
extraMessage: response
};
}).catch(error => ({
status: 102,
statusText: 'Request Error',
extraMessage: error
}));
}
}
exports.PushBullet = PushBullet;
Loading

0 comments on commit 8abb4a3

Please sign in to comment.