bark支持自定义推送图标 (#1146)

* bark添加自定义推送图标

* 脚本bark通知添加自定义推送图标
This commit is contained in:
Ukenn 2022-02-08 18:21:37 +08:00 committed by GitHub
parent e154cf65b6
commit 89e08953cb
6 changed files with 30 additions and 14 deletions

View File

@ -34,6 +34,7 @@ export class ServerChanNotification extends NotificationBaseInfo {
export class BarkNotification extends NotificationBaseInfo {
public barkPush = '';
public barkIcon = 'https://lf9-survey.bytetos.com/obj/web.business.image/202201205d0d7b5e576ee603497ab6f3';
public barkSound = '';
public barkGroup = 'qinglong';
}

View File

@ -119,7 +119,7 @@ export default class NotificationService {
}
private async bark() {
let { barkPush, barkSound, barkGroup } = this.params;
let { barkPush, barkIcon, barkSound, barkGroup } = this.params;
if (!barkPush.startsWith('http') && !barkPush.startsWith('https')) {
barkPush = `https://api.day.app/${barkPush}`;
}
@ -127,7 +127,7 @@ export default class NotificationService {
this.title,
)}/${encodeURIComponent(
this.content,
)}?sound=${barkSound}&group=${barkGroup}`;
)}?icon=${barkIcon}?sound=${barkSound}&group=${barkGroup}`;
const res: any = await got
.get(url, {
timeout: this.timeout,

View File

@ -50,6 +50,8 @@ export PUSH_KEY=""
## 2. BARK
## 下方填写app提供的设备码例如https://api.day.app/123 那么此处的设备码就是123
export BARK_PUSH=""
## 下方填写推送图标设置,自定义推送图标(需iOS15或以上)
export BARK_ICON="https://lf9-survey.bytetos.com/obj/web.business.image/202201205d0d7b5e576ee603497ab6f3"
## 下方填写推送声音设置例如choo具体值请在bark-推送铃声-查看所有铃声
export BARK_SOUND=""
## 下方填写推送消息分组,默认为"QingLong"

View File

@ -37,6 +37,9 @@ let SCKEY = '';
// =======================================Bark App通知设置区域===========================================
//此处填你BarkAPP的信息(IP/设备码例如https://api.day.app/XXXXXXXX)
let BARK_PUSH = '';
//BARK app推送图标,自定义推送图标(需iOS15或以上)
let BARK_ICON =
'https://lf9-survey.bytetos.com/obj/web.business.image/202201205d0d7b5e576ee603497ab6f3';
//BARK app推送铃声,铃声列表去APP查看复制填写
let BARK_SOUND = '';
//BARK app推送消息的分组, 默认为"QingLong"
@ -133,6 +136,9 @@ if (process.env.BARK_PUSH) {
} else {
BARK_PUSH = `https://api.day.app/${process.env.BARK_PUSH}`;
}
if (process.env.BARK_ICON) {
BARK_ICON = process.env.BARK_ICON;
}
if (process.env.BARK_SOUND) {
BARK_SOUND = process.env.BARK_SOUND;
}
@ -216,8 +222,8 @@ async function sendNotify(
qywxBotNotify(text, desp), //企业微信机器人
qywxamNotify(text, desp), //企业微信应用消息推送
iGotNotify(text, desp, params), //iGot
gobotNotify(text, desp),//go-cqhttp
gotifyNotify(text, desp),//gotify
gobotNotify(text, desp), //go-cqhttp
gotifyNotify(text, desp), //gotify
]);
}
@ -226,10 +232,12 @@ function gotifyNotify(text, desp) {
if (GOTIFY_URL && GOTIFY_TOKEN) {
const options = {
url: `${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}`,
body: `title=${encodeURIComponent(text)}&message=${encodeURIComponent(desp)}&priority=${GOTIFY_PRIORITY}`,
body: `title=${encodeURIComponent(text)}&message=${encodeURIComponent(
desp,
)}&priority=${GOTIFY_PRIORITY}`,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
}
},
};
$.post(options, (err, resp, data) => {
try {
@ -261,7 +269,7 @@ function gobotNotify(text, desp, time = 2100) {
if (GOBOT_URL) {
const options = {
url: `${GOBOT_URL}?access_token=${GOBOT_TOKEN}&${GOBOT_QQ}`,
json: {message:`${text}\n${desp}`},
json: { message: `${text}\n${desp}` },
headers: {
'Content-Type': 'application/json',
},
@ -429,7 +437,9 @@ function BarkNotify(text, desp, params = {}) {
const options = {
url: `${BARK_PUSH}/${encodeURIComponent(text)}/${encodeURIComponent(
desp,
)}?sound=${BARK_SOUND}&group=${BARK_GROUP}&${querystring.stringify(params)}`,
)}?icon=${BARK_ICON}?sound=${BARK_SOUND}&group=${BARK_GROUP}&${querystring.stringify(
params,
)}`,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
@ -726,8 +736,8 @@ function qywxamNotify(text, desp) {
if (err) {
console.log(
'成员ID:' +
ChangeUserId(desp) +
'企业微信应用消息发送通知消息失败!!\n',
ChangeUserId(desp) +
'企业微信应用消息发送通知消息失败!!\n',
);
console.log(err);
} else {
@ -735,8 +745,8 @@ function qywxamNotify(text, desp) {
if (data.errcode === 0) {
console.log(
'成员ID:' +
ChangeUserId(desp) +
'企业微信应用消息发送通知消息成功🎉。\n',
ChangeUserId(desp) +
'企业微信应用消息发送通知消息成功🎉。\n',
);
} else {
console.log(`${data.errmsg}\n`);

View File

@ -35,6 +35,7 @@ push_config = {
'BARK_ARCHIVE': '', # bark 推送是否存档
'BARK_GROUP': '', # bark 推送分组
'BARK_SOUND': '', # bark 推送声音
'BARK_ICON': '', # bark 推送图标
'CONSOLE': True, # 控制台输出
@ -104,6 +105,7 @@ def bark(title: str, content: str) -> None:
"BARK_ARCHIVE": "isArchive",
"BARK_GROUP": "group",
"BARK_SOUND": "sound",
"BARK_ICON": "icon",
}
params = ""
for pair in filter(

View File

@ -119,6 +119,7 @@ export default {
tip: 'Bark的信息IP/设备码例如https://api.day.app/XXXXXXXX',
required: true,
},
{ label: 'barkIcon', tip: 'BARK推送图标,自定义推送图标 (需iOS15或以上才能显示)' },
{ label: 'barkSound', tip: 'BARK推送铃声,铃声列表去APP查看复制填写' },
{ label: 'barkGroup', tip: 'BARK推送消息的分组, 默认为qinglong' },
],