diff --git a/back/data/notify.ts b/back/data/notify.ts index a28e0721..aa4887b9 100644 --- a/back/data/notify.ts +++ b/back/data/notify.ts @@ -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'; } diff --git a/back/services/notify.ts b/back/services/notify.ts index 84119d7c..1a12abd0 100644 --- a/back/services/notify.ts +++ b/back/services/notify.ts @@ -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, diff --git a/sample/config.sample.sh b/sample/config.sample.sh index e9740735..e7eb8b0f 100644 --- a/sample/config.sample.sh +++ b/sample/config.sample.sh @@ -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" diff --git a/sample/notify.js b/sample/notify.js index 12b7cfeb..0e4590ac 100644 --- a/sample/notify.js +++ b/sample/notify.js @@ -25,9 +25,9 @@ let GOTIFY_PRIORITY = 0; //gobot_token 填写在go-cqhttp文件设置的访问密钥 //gobot_qq 填写推送到个人QQ或者QQ群号 //go-cqhttp相关API https://docs.go-cqhttp.org/api -let GOBOT_URL = ''; // 推送到个人QQ: http://127.0.0.1/send_private_msg 群:http://127.0.0.1/send_group_msg +let GOBOT_URL = ''; // 推送到个人QQ: http://127.0.0.1/send_private_msg 群:http://127.0.0.1/send_group_msg let GOBOT_TOKEN = ''; //访问密钥 -let GOBOT_QQ = ''; // 如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群 +let GOBOT_QQ = ''; // 如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群 // =======================================微信server酱通知设置区域=========================================== //此处填你申请的SCKEY. @@ -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`); diff --git a/sample/notify.py b/sample/notify.py index a5ac2b76..75c3bbd2 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -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( diff --git a/src/utils/config.ts b/src/utils/config.ts index 0b21d04f..3a5d4a04 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -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' }, ],