增加系统通知、去除注释

This commit is contained in:
child 2023-10-12 13:24:13 +08:00
parent bbac6aba4b
commit cd50156f5d
3 changed files with 130 additions and 94 deletions

View File

@ -374,7 +374,7 @@ async function sendNotify(
fsBotNotify(text, desp), //飞书机器人 fsBotNotify(text, desp), //飞书机器人
smtpNotify(text, desp), //SMTP 邮件 smtpNotify(text, desp), //SMTP 邮件
PushMeNotify(text, desp, params), //PushMe PushMeNotify(text, desp, params), //PushMe
ChronocatNotify(text, desp) // Chronocat ChronocatNotify(text, desp), // Chronocat
]); ]);
} }
@ -1193,44 +1193,48 @@ function PushMeNotify(text, desp, params = {}) {
function ChronocatNotify(title, desp) { function ChronocatNotify(title, desp) {
return new Promise((resolve) => { return new Promise((resolve) => {
// 检查 CHRONOCAT 的配置是否完整
if (!CHRONOCAT_TOKEN || !CHRONOCAT_QQ || !CHRONOCAT_URL) { if (!CHRONOCAT_TOKEN || !CHRONOCAT_QQ || !CHRONOCAT_URL) {
console.log("CHRONOCAT 服务的 CHRONOCAT_URL 或 CHRONOCAT_QQ 未设置!!\n取消推送"); console.log(
'CHRONOCAT 服务的 CHRONOCAT_URL 或 CHRONOCAT_QQ 未设置!!\n取消推送',
);
return; return;
} }
console.log("CHRONOCAT 服务启动"); console.log('CHRONOCAT 服务启动');
const user_ids = CHRONOCAT_QQ.match(/user_id=(\d+)/g)?.map(
(match) => match.split('=')[1],
);
const group_ids = CHRONOCAT_QQ.match(/group_id=(\d+)/g)?.map(
(match) => match.split('=')[1],
);
// 提取 user_id 和 group_id
const user_ids = CHRONOCAT_QQ.match(/user_id=(\d+)/g)?.map(match => match.split("=")[1]);
const group_ids = CHRONOCAT_QQ.match(/group_id=(\d+)/g)?.map(match => match.split("=")[1]);
// 设置请求的 URL 和 Headers
const url = `${CHRONOCAT_URL}/api/message/send`; const url = `${CHRONOCAT_URL}/api/message/send`;
const headers = { const headers = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': `Bearer ${CHRONOCAT_TOKEN}` Authorization: `Bearer ${CHRONOCAT_TOKEN}`,
}; };
// 发送消息 for (const [chat_type, ids] of [
for (const [chat_type, ids] of [[1, user_ids], [2, group_ids]]) { [1, user_ids],
[2, group_ids],
]) {
if (!ids) { if (!ids) {
continue; continue;
} }
for (const chat_id of ids) { for (const chat_id of ids) {
const data = { const data = {
"peer": { peer: {
"chatType": chat_type, chatType: chat_type,
"peerUin": chat_id peerUin: chat_id,
}, },
"elements": [ elements: [
{ {
"elementType": 1, elementType: 1,
"textElement": { textElement: {
"content": `${title}\n\n${desp}` content: `${title}\n\n${desp}`,
} },
} },
] ],
}; };
const options = { const options = {
url: url, url: url,
@ -1250,11 +1254,6 @@ function ChronocatNotify(title, desp) {
} else { } else {
console.log(`QQ群消息:${ids}推送成功!`); console.log(`QQ群消息:${ids}推送成功!`);
} }
// if (data.code === 0) {
// console.log('智能微秘书发送通知消息成功🎉。\n');
// } else {
// console.log(`${data.error}\n`);
// }
} }
} catch (e) { } catch (e) {
$.logErr(e, resp); $.logErr(e, resp);
@ -1264,11 +1263,9 @@ function ChronocatNotify(title, desp) {
}); });
} }
} }
}) });
} }
module.exports = { module.exports = {
sendNotify, sendNotify,
BARK_PUSH, BARK_PUSH,

View File

@ -671,7 +671,6 @@ def chronocat(title: str, content: str) -> None:
""" """
使用 CHRONOCAT 推送消息 使用 CHRONOCAT 推送消息
""" """
# 检查 CHRONOCAT 的配置是否完整
if not push_config.get("CHRONOCAT_URL") or not push_config.get("CHRONOCAT_QQ") or not push_config.get( if not push_config.get("CHRONOCAT_URL") or not push_config.get("CHRONOCAT_QQ") or not push_config.get(
"CHRONOCAT_TOKEN"): "CHRONOCAT_TOKEN"):
print("CHRONOCAT 服务的 CHRONOCAT_URL 或 CHRONOCAT_QQ 未设置!!\n取消推送") print("CHRONOCAT 服务的 CHRONOCAT_URL 或 CHRONOCAT_QQ 未设置!!\n取消推送")
@ -679,18 +678,15 @@ def chronocat(title: str, content: str) -> None:
print("CHRONOCAT 服务启动") print("CHRONOCAT 服务启动")
# 提取 user_id 和 group_id
user_ids = re.findall(r"user_id=(\d+)", push_config.get("CHRONOCAT_QQ")) user_ids = re.findall(r"user_id=(\d+)", push_config.get("CHRONOCAT_QQ"))
group_ids = re.findall(r"group_id=(\d+)", push_config.get("CHRONOCAT_QQ")) group_ids = re.findall(r"group_id=(\d+)", push_config.get("CHRONOCAT_QQ"))
# 设置请求的 URL 和 Headers
url = f'{push_config.get("CHRONOCAT_URL")}/api/message/send' url = f'{push_config.get("CHRONOCAT_URL")}/api/message/send'
headers = { headers = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': f'Bearer {push_config.get("CHRONOCAT_TOKEN")}' 'Authorization': f'Bearer {push_config.get("CHRONOCAT_TOKEN")}'
} }
# 发送消息
for chat_type, ids in [(1, user_ids), (2, group_ids)]: for chat_type, ids in [(1, user_ids), (2, group_ids)]:
if not ids: if not ids:
continue continue

View File

@ -98,6 +98,7 @@ export default {
{ value: 'email', label: intl.get('邮箱') }, { value: 'email', label: intl.get('邮箱') },
{ value: 'lark', label: intl.get('飞书机器人') }, { value: 'lark', label: intl.get('飞书机器人') },
{ value: 'pushMe', label: 'PushMe' }, { value: 'pushMe', label: 'PushMe' },
{ value: 'chronocat', label: 'Chronocat' },
{ value: 'webhook', label: intl.get('自定义通知') }, { value: 'webhook', label: intl.get('自定义通知') },
{ value: 'closed', label: intl.get('已关闭') }, { value: 'closed', label: intl.get('已关闭') },
], ],
@ -126,14 +127,16 @@ export default {
goCqHttpBot: [ goCqHttpBot: [
{ {
label: 'goCqHttpBotUrl', label: 'goCqHttpBotUrl',
tip: intl.get('推送到个人QQ: http://127.0.0.1/send_private_msghttp://127.0.0.1/send_group_msg', tip: intl.get(
'推送到个人QQ: http://127.0.0.1/send_private_msghttp://127.0.0.1/send_group_msg',
), ),
required: true, required: true,
}, },
{ label: 'goCqHttpBotToken', tip: intl.get('访问密钥'), required: true }, { label: 'goCqHttpBotToken', tip: intl.get('访问密钥'), required: true },
{ {
label: 'goCqHttpBotQq', label: 'goCqHttpBotQq',
tip: intl.get('如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群', tip: intl.get(
'如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群',
), ),
required: true, required: true,
}, },
@ -153,14 +156,16 @@ export default {
}, },
{ {
label: 'pushDeerUrl', label: 'pushDeerUrl',
tip: intl.get('PushDeer的自架API endpoint默认是 https://api2.pushdeer.com/message/push', tip: intl.get(
'PushDeer的自架API endpoint默认是 https://api2.pushdeer.com/message/push',
), ),
}, },
], ],
bark: [ bark: [
{ {
label: 'barkPush', label: 'barkPush',
tip: intl.get('Bark的信息IP/设备码例如https://api.day.app/XXXXXXXX', tip: intl.get(
'Bark的信息IP/设备码例如https://api.day.app/XXXXXXXX',
), ),
required: true, required: true,
}, },
@ -188,7 +193,8 @@ export default {
telegramBot: [ telegramBot: [
{ {
label: 'telegramBotToken', label: 'telegramBotToken',
tip: intl.get('telegram机器人的token例如1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw', tip: intl.get(
'telegram机器人的token例如1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw',
), ),
required: true, required: true,
}, },
@ -201,7 +207,8 @@ export default {
{ label: 'telegramBotProxyPort', tip: intl.get('代理端口') }, { label: 'telegramBotProxyPort', tip: intl.get('代理端口') },
{ {
label: 'telegramBotProxyAuth', label: 'telegramBotProxyAuth',
tip: intl.get('telegram代理配置认证参数用户名与密码用英文冒号连接 user:password', tip: intl.get(
'telegram代理配置认证参数用户名与密码用英文冒号连接 user:password',
), ),
}, },
{ {
@ -212,20 +219,23 @@ export default {
dingtalkBot: [ dingtalkBot: [
{ {
label: 'dingtalkBotToken', label: 'dingtalkBotToken',
tip: intl.get('钉钉机器人webhook token例如5a544165465465645d0f31dca676e7bd07415asdasd', tip: intl.get(
'钉钉机器人webhook token例如5a544165465465645d0f31dca676e7bd07415asdasd',
), ),
required: true, required: true,
}, },
{ {
label: 'dingtalkBotSecret', label: 'dingtalkBotSecret',
tip: intl.get('密钥机器人安全设置页面加签一栏下面显示的SEC开头的字符串', tip: intl.get(
'密钥机器人安全设置页面加签一栏下面显示的SEC开头的字符串',
), ),
}, },
], ],
weWorkBot: [ weWorkBot: [
{ {
label: 'weWorkBotKey', label: 'weWorkBotKey',
tip: intl.get('企业微信机器人的webhook(详见文档 https://work.weixin.qq.com/api/doc/90000/90136/91770)例如693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa', tip: intl.get(
'企业微信机器人的webhook(详见文档 https://work.weixin.qq.com/api/doc/90000/90136/91770)例如693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa',
), ),
required: true, required: true,
}, },
@ -237,7 +247,8 @@ export default {
weWorkApp: [ weWorkApp: [
{ {
label: 'weWorkAppKey', label: 'weWorkAppKey',
tip: intl.get('corpid、corpsecret、touser(注:多个成员ID使用|隔开)、agentid、消息类型(选填,不填默认文本消息类型) 注意用,号隔开(英文输入法的逗号)例如wwcfrs,B-76WERQ,qinglong,1000001,2COat', tip: intl.get(
'corpid、corpsecret、touser(注:多个成员ID使用|隔开)、agentid、消息类型(选填,不填默认文本消息类型) 注意用,号隔开(英文输入法的逗号)例如wwcfrs,B-76WERQ,qinglong,1000001,2COat',
), ),
required: true, required: true,
}, },
@ -249,7 +260,8 @@ export default {
aibotk: [ aibotk: [
{ {
label: 'aibotkKey', label: 'aibotkKey',
tip: intl.get('密钥key智能微秘书个人中心获取apikey申请地址https://wechat.aibotk.com/signup?from=ql', tip: intl.get(
'密钥key智能微秘书个人中心获取apikey申请地址https://wechat.aibotk.com/signup?from=ql',
), ),
required: true, required: true,
}, },
@ -265,7 +277,8 @@ export default {
}, },
{ {
label: 'aibotkName', label: 'aibotkName',
tip: intl.get('要发送的用户昵称或群名,如果目标是群,需要填群名,如果目标是好友,需要填好友昵称', tip: intl.get(
'要发送的用户昵称或群名,如果目标是群,需要填群名,如果目标是好友,需要填好友昵称',
), ),
required: true, required: true,
}, },
@ -273,7 +286,8 @@ export default {
iGot: [ iGot: [
{ {
label: 'iGotPushKey', label: 'iGotPushKey',
tip: intl.get('iGot的信息推送key例如https://push.hellyw.com/XXXXXXXX', tip: intl.get(
'iGot的信息推送key例如https://push.hellyw.com/XXXXXXXX',
), ),
required: true, required: true,
}, },
@ -281,20 +295,23 @@ export default {
pushPlus: [ pushPlus: [
{ {
label: 'pushPlusToken', label: 'pushPlusToken',
tip: intl.get('微信扫码登录后一对一推送或一对多推送下面的token(您的Token)不提供PUSH_PLUS_USER则默认为一对一推送参考 https://www.pushplus.plus/', tip: intl.get(
'微信扫码登录后一对一推送或一对多推送下面的token(您的Token)不提供PUSH_PLUS_USER则默认为一对一推送参考 https://www.pushplus.plus/',
), ),
required: true, required: true,
}, },
{ {
label: 'pushPlusUser', label: 'pushPlusUser',
tip: intl.get('一对多推送的“群组编码”(一对多推送下面->您的群组(如无则创建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)', tip: intl.get(
'一对多推送的“群组编码”(一对多推送下面->您的群组(如无则创建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)',
), ),
}, },
], ],
lark: [ lark: [
{ {
label: 'larkKey', label: 'larkKey',
tip: intl.get('飞书群组机器人https://www.feishu.cn/hc/zh-CN/articles/360024984973', tip: intl.get(
'飞书群组机器人https://www.feishu.cn/hc/zh-CN/articles/360024984973',
), ),
required: true, required: true,
}, },
@ -302,7 +319,8 @@ export default {
email: [ email: [
{ {
label: 'emailService', label: 'emailService',
tip: intl.get('邮箱服务名称比如126、163、Gmail、QQ等支持列表https://nodemailer.com/smtp/well-known/', tip: intl.get(
'邮箱服务名称比如126、163、Gmail、QQ等支持列表https://nodemailer.com/smtp/well-known/',
), ),
required: true, required: true,
}, },
@ -316,6 +334,29 @@ export default {
required: true, required: true,
}, },
], ],
chronocat: [
{
label: 'chronocatURL',
tip: intl.get(
'Chronocat Red 服务的连接地址 https://chronocat.vercel.app/install/docker/official/',
),
required: true,
},
{
label: 'chronocatQQ',
tip: intl.get(
'个人:user_id=个人QQ 群则填入group_id=QQ群 多个用英文;隔开同时支持个人和群 如user_id=xxx;group_id=xxxx;group_id=xxxxx',
),
required: true,
},
{
label: 'chronocatToken',
tip: intl.get(
'docker安装在持久化config目录下的chronocat.yml文件可找到',
),
required: true,
},
],
webhook: [ webhook: [
{ {
label: 'webhookMethod', label: 'webhookMethod',
@ -335,7 +376,8 @@ export default {
}, },
{ {
label: 'webhookUrl', label: 'webhookUrl',
tip: intl.get('请求链接以http或者https开头。url或者body中必须包含$title$content可选对应api内容的位置', tip: intl.get(
'请求链接以http或者https开头。url或者body中必须包含$title$content可选对应api内容的位置',
), ),
required: true, required: true,
placeholder: 'https://xxx.cn/api?content=$title\n', placeholder: 'https://xxx.cn/api?content=$title\n',
@ -347,7 +389,8 @@ export default {
}, },
{ {
label: 'webhookBody', label: 'webhookBody',
tip: intl.get('请求体格式key1: value1多个换行分割。url或者body中必须包含$title$content可选对应api内容的位置', tip: intl.get(
'请求体格式key1: value1多个换行分割。url或者body中必须包含$title$content可选对应api内容的位置',
), ),
placeholder: 'key1: $title\nkey2: $content', placeholder: 'key1: $title\nkey2: $content',
}, },