From 36e1f231c6ce186de3ad7d60185669fc20669534 Mon Sep 17 00:00:00 2001 From: beanjs <445212619@qq.com> Date: Sat, 28 Sep 2024 14:36:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=8E=AF=E5=A2=83=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E5=90=8D=E4=B8=8E=E7=A8=8B=E5=BA=8F=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=90=8D=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/data/notify.ts | 50 ++++++++++----------- back/services/notify.ts | 96 ++++++++++++++++++++--------------------- src/utils/config.ts | 50 ++++++++++----------- 3 files changed, 98 insertions(+), 98 deletions(-) diff --git a/back/data/notify.ts b/back/data/notify.ts index 6264b56c..4efc4504 100644 --- a/back/data/notify.ts +++ b/back/data/notify.ts @@ -33,18 +33,18 @@ export class GotifyNotification extends NotificationBaseInfo { } export class GoCqHttpBotNotification extends NotificationBaseInfo { - public goCqHttpBotUrl = ''; - public goCqHttpBotToken = ''; - public goCqHttpBotQq = ''; + public gobotUrl = ''; + public gobotToken = ''; + public gobotQq = ''; } export class ServerChanNotification extends NotificationBaseInfo { - public serverChanKey = ''; + public pushKey = ''; } export class PushDeerNotification extends NotificationBaseInfo { - public pushDeerKey = ''; - public pushDeerUrl = ''; + public deerKey = ''; + public deerUrl = ''; } export class ChatNotification extends NotificationBaseInfo { @@ -63,27 +63,27 @@ export class BarkNotification extends NotificationBaseInfo { } export class TelegramBotNotification extends NotificationBaseInfo { - public telegramBotToken = ''; - public telegramBotUserId = ''; - public telegramBotProxyHost = ''; - public telegramBotProxyPort = ''; - public telegramBotProxyAuth = ''; - public telegramBotApiHost = 'https://api.telegram.org'; + public tgBotToken = ''; + public tgUserId = ''; + public tgProxyHost = ''; + public tgProxyPort = ''; + public tgProxyAuth = ''; + public tgApiHost = 'https://api.telegram.org'; } export class DingtalkBotNotification extends NotificationBaseInfo { - public dingtalkBotToken = ''; - public dingtalkBotSecret = ''; + public ddBotToken = ''; + public ddBotSecret = ''; } export class WeWorkBotNotification extends NotificationBaseInfo { - public weWorkBotKey = ''; - public weWorkOrigin = ''; + public qywxKey = ''; + public qywxOrigin = ''; } export class WeWorkAppNotification extends NotificationBaseInfo { - public weWorkAppKey = ''; - public weWorkOrigin = ''; + public qywxKey = ''; + public qywxOrigin = ''; } export class AibotkNotification extends NotificationBaseInfo { @@ -93,7 +93,7 @@ export class AibotkNotification extends NotificationBaseInfo { } export class IGotNotification extends NotificationBaseInfo { - public iGotPushKey = ''; + public igotPushKey = ''; } export class PushPlusNotification extends NotificationBaseInfo { @@ -108,14 +108,14 @@ export class WePlusBotNotification extends NotificationBaseInfo { } export class EmailNotification extends NotificationBaseInfo { - public emailService: string = ''; - public emailUser: string = ''; - public emailPass: string = ''; + public smtpService: string = ''; + public smtpName: string = ''; + public smtpPassword: string = ''; } export class PushMeNotification extends NotificationBaseInfo { - public pushMeKey: string = ''; - public pushMeUrl: string = ''; + public pushmeKey: string = ''; + public pushmeUrl: string = ''; } export class ChronocatNotification extends NotificationBaseInfo { @@ -136,7 +136,7 @@ export class WebhookNotification extends NotificationBaseInfo { } export class LarkNotification extends NotificationBaseInfo { - public larkKey = ''; + public fskey = ''; } export interface NotificationInfo diff --git a/back/services/notify.ts b/back/services/notify.ts index fcdd3c12..4abf350b 100644 --- a/back/services/notify.ts +++ b/back/services/notify.ts @@ -130,13 +130,13 @@ export default class NotificationService { } private async goCqHttpBot() { - const { goCqHttpBotQq, goCqHttpBotToken, goCqHttpBotUrl } = this.params; + const { gobotQq, gobotToken, gobotUrl } = this.params; try { const res: any = await got - .post(`${goCqHttpBotUrl}?${goCqHttpBotQq}`, { + .post(`${gobotUrl}?${gobotQq}`, { ...this.gotOption, json: { message: `${this.title}\n${this.content}` }, - headers: { Authorization: 'Bearer ' + goCqHttpBotToken }, + headers: { Authorization: 'Bearer ' + gobotToken }, }) .json(); if (res.retcode === 0) { @@ -150,10 +150,10 @@ export default class NotificationService { } private async serverChan() { - const { serverChanKey } = this.params; - const url = serverChanKey.startsWith('SCT') - ? `https://sctapi.ftqq.com/${serverChanKey}.send` - : `https://sc.ftqq.com/${serverChanKey}.send`; + const { pushKey } = this.params; + const url = pushKey.startsWith('SCT') + ? `https://sctapi.ftqq.com/${pushKey}.send` + : `https://sc.ftqq.com/${pushKey}.send`; try { const res: any = await got .post(url, { @@ -173,13 +173,13 @@ export default class NotificationService { } private async pushDeer() { - const { pushDeerKey, pushDeerUrl } = this.params; - const url = pushDeerUrl || `https://api2.pushdeer.com/message/push`; + const { deerKey, deerUrl } = this.params; + const url = deerUrl || `https://api2.pushdeer.com/message/push`; try { const res: any = await got .post(url, { ...this.gotOption, - body: `pushkey=${pushDeerKey}&text=${encodeURIComponent( + body: `pushkey=${deerKey}&text=${encodeURIComponent( this.title, )}&desp=${encodeURIComponent(this.content)}&type=markdown`, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, @@ -263,25 +263,25 @@ export default class NotificationService { private async telegramBot() { const { - telegramBotApiHost, - telegramBotProxyAuth, - telegramBotProxyHost, - telegramBotProxyPort, - telegramBotToken, - telegramBotUserId, + tgApiHost, + tgProxyAuth, + tgProxyHost, + tgProxyPort, + tgBotToken, + tgUserId, } = this.params; - const authStr = telegramBotProxyAuth ? `${telegramBotProxyAuth}@` : ''; + const authStr = tgProxyAuth ? `${tgProxyAuth}@` : ''; const url = `${ - telegramBotApiHost ? telegramBotApiHost : 'https://api.telegram.org' - }/bot${telegramBotToken}/sendMessage`; + tgApiHost ? tgApiHost : 'https://api.telegram.org' + }/bot${tgBotToken}/sendMessage`; let agent; - if (telegramBotProxyHost && telegramBotProxyPort) { + if (tgProxyHost && tgProxyPort) { const options: any = { keepAlive: true, keepAliveMsecs: 1000, maxSockets: 256, maxFreeSockets: 256, - proxy: `http://${authStr}${telegramBotProxyHost}:${telegramBotProxyPort}`, + proxy: `http://${authStr}${tgProxyHost}:${tgProxyPort}`, }; const httpAgent = new HttpProxyAgent(options); const httpsAgent = new HttpsProxyAgent(options); @@ -294,7 +294,7 @@ export default class NotificationService { const res: any = await got .post(url, { ...this.gotOption, - body: `chat_id=${telegramBotUserId}&text=${this.title}\n\n${this.content}&disable_web_page_preview=true`, + body: `chat_id=${tgUserId}&text=${this.title}\n\n${this.content}&disable_web_page_preview=true`, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, agent, }) @@ -310,16 +310,16 @@ export default class NotificationService { } private async dingtalkBot() { - const { dingtalkBotSecret, dingtalkBotToken } = this.params; + const { ddBotSecret, ddBotToken } = this.params; let secretParam = ''; - if (dingtalkBotSecret) { + if (ddBotSecret) { const dateNow = Date.now(); - const hmac = crypto.createHmac('sha256', dingtalkBotSecret); - hmac.update(`${dateNow}\n${dingtalkBotSecret}`); + const hmac = crypto.createHmac('sha256', ddBotSecret); + hmac.update(`${dateNow}\n${ddBotSecret}`); const result = encodeURIComponent(hmac.digest('base64')); secretParam = `×tamp=${dateNow}&sign=${result}`; } - const url = `https://oapi.dingtalk.com/robot/send?access_token=${dingtalkBotToken}${secretParam}`; + const url = `https://oapi.dingtalk.com/robot/send?access_token=${ddBotToken}${secretParam}`; try { const res: any = await got .post(url, { @@ -343,9 +343,9 @@ export default class NotificationService { } private async weWorkBot() { - const { weWorkBotKey, weWorkOrigin = 'https://qyapi.weixin.qq.com' } = + const { qywxKey, qywxOrigin = 'https://qyapi.weixin.qq.com' } = this.params; - const url = `${weWorkOrigin}/cgi-bin/webhook/send?key=${weWorkBotKey}`; + const url = `${qywxOrigin}/cgi-bin/webhook/send?key=${qywxKey}`; try { const res: any = await got .post(url, { @@ -369,11 +369,11 @@ export default class NotificationService { } private async weWorkApp() { - const { weWorkAppKey, weWorkOrigin = 'https://qyapi.weixin.qq.com' } = + const { qywxKey, qywxOrigin = 'https://qyapi.weixin.qq.com' } = this.params; const [corpid, corpsecret, touser, agentid, thumb_media_id = '1'] = - weWorkAppKey.split(','); - const url = `${weWorkOrigin}/cgi-bin/gettoken`; + qywxKey.split(','); + const url = `${qywxOrigin}/cgi-bin/gettoken`; const tokenRes: any = await got .post(url, { ...this.gotOption, @@ -425,7 +425,7 @@ export default class NotificationService { try { const res: any = await got .post( - `${weWorkOrigin}/cgi-bin/message/send?access_token=${tokenRes.access_token}`, + `${qywxOrigin}/cgi-bin/message/send?access_token=${tokenRes.access_token}`, { ...this.gotOption, json: { @@ -497,8 +497,8 @@ export default class NotificationService { } private async iGot() { - const { iGotPushKey } = this.params; - const url = `https://push.hellyw.com/${iGotPushKey.toLowerCase()}`; + const { igotPushKey } = this.params; + const url = `https://push.hellyw.com/${igotPushKey.toLowerCase()}`; try { const res: any = await got .post(url, { @@ -581,15 +581,15 @@ export default class NotificationService { } private async lark() { - let { larkKey } = this.params; + let { fskey } = this.params; - if (!larkKey.startsWith('http')) { - larkKey = `https://open.feishu.cn/open-apis/bot/v2/hook/${larkKey}`; + if (!fskey.startsWith('http')) { + fskey = `https://open.feishu.cn/open-apis/bot/v2/hook/${fskey}`; } try { const res: any = await got - .post(larkKey, { + .post(fskey, { ...this.gotOption, json: { msg_type: 'text', @@ -609,20 +609,20 @@ export default class NotificationService { } private async email() { - const { emailPass, emailService, emailUser } = this.params; + const { smtpPassword, smtpService, smtpName } = this.params; try { const transporter = nodemailer.createTransport({ - service: emailService, + service: smtpService, auth: { - user: emailUser, - pass: emailPass, + user: smtpName, + pass: smtpPassword, }, }); const info = await transporter.sendMail({ - from: `"青龙快讯" <${emailUser}>`, - to: `${emailUser}`, + from: `"青龙快讯" <${smtpName}>`, + to: `${smtpName}`, subject: `${this.title}`, html: `${this.content.replace(/\n/g, '
')}`, }); @@ -640,12 +640,12 @@ export default class NotificationService { } private async pushMe() { - const { pushMeKey, pushMeUrl } = this.params; + const { pushmeKey, pushmeUrl } = this.params; try { - const res: any = await got.post(pushMeUrl || 'https://push.i-i.me/', { + const res: any = await got.post(pushmeUrl || 'https://push.i-i.me/', { ...this.gotOption, json: { - push_key: pushMeKey, + push_key: pushmeKey, title: this.title, content: this.content, }, diff --git a/src/utils/config.ts b/src/utils/config.ts index 4859f60a..55cd674b 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -128,15 +128,15 @@ export default { ], goCqHttpBot: [ { - label: 'goCqHttpBotUrl', + label: 'gobotUrl', tip: intl.get( '推送到个人QQ: http://127.0.0.1/send_private_msg,群:http://127.0.0.1/send_group_msg', ), required: true, }, - { label: 'goCqHttpBotToken', tip: intl.get('访问密钥'), required: true }, + { label: 'gobotToken', tip: intl.get('访问密钥'), required: true }, { - label: 'goCqHttpBotQq', + label: 'gobotQq', tip: intl.get( '如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群', ), @@ -145,19 +145,19 @@ export default { ], serverChan: [ { - label: 'serverChanKey', + label: 'pushKey', tip: intl.get('Server酱SENDKEY'), required: true, }, ], pushDeer: [ { - label: 'pushDeerKey', + label: 'deerKey', tip: intl.get('PushDeer的Key,https://github.com/easychen/pushdeer'), required: true, }, { - label: 'pushDeerUrl', + label: 'deerUrl', tip: intl.get( 'PushDeer的自架API endpoint,默认是 https://api2.pushdeer.com/message/push', ), @@ -198,40 +198,40 @@ export default { ], telegramBot: [ { - label: 'telegramBotToken', + label: 'tgBotToken', tip: intl.get( 'telegram机器人的token,例如:1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw', ), required: true, }, { - label: 'telegramBotUserId', + label: 'tgUserId', tip: intl.get('telegram用户的id,例如:129xxx206'), required: true, }, - { label: 'telegramBotProxyHost', tip: intl.get('代理IP') }, - { label: 'telegramBotProxyPort', tip: intl.get('代理端口') }, + { label: 'tgProxyHost', tip: intl.get('代理IP') }, + { label: 'tgProxyPort', tip: intl.get('代理端口') }, { - label: 'telegramBotProxyAuth', + label: 'tgProxyAuth', tip: intl.get( 'telegram代理配置认证参数,用户名与密码用英文冒号连接 user:password', ), }, { - label: 'telegramBotApiHost', + label: 'tgApiHost', tip: intl.get('telegram api自建的反向代理地址,默认tg官方api'), }, ], dingtalkBot: [ { - label: 'dingtalkBotToken', + label: 'ddBotToken', tip: intl.get( '钉钉机器人webhook token,例如:5a544165465465645d0f31dca676e7bd07415asdasd', ), required: true, }, { - label: 'dingtalkBotSecret', + label: 'ddBotSecret', tip: intl.get( '密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的字符串', ), @@ -239,27 +239,27 @@ export default { ], weWorkBot: [ { - label: 'weWorkBotKey', + label: 'qywxKey', tip: intl.get( '企业微信机器人的webhook(详见文档 https://work.weixin.qq.com/api/doc/90000/90136/91770),例如:693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa', ), required: true, }, { - label: 'weWorkOrigin', + label: 'qywxOrigin', tip: intl.get('企业微信代理地址'), }, ], weWorkApp: [ { - label: 'weWorkAppKey', + label: 'qywxKey', tip: intl.get( 'corpid、corpsecret、touser(注:多个成员ID使用|隔开)、agentid、消息类型(选填,不填默认文本消息类型) 注意用,号隔开(英文输入法的逗号),例如:wwcfrs,B-76WERQ,qinglong,1000001,2COat', ), required: true, }, { - label: 'weWorkOrigin', + label: 'qywxOrigin', tip: intl.get('企业微信代理地址'), }, ], @@ -291,7 +291,7 @@ export default { ], iGot: [ { - label: 'iGotPushKey', + label: 'igotPushKey', tip: intl.get( 'iGot的信息推送key,例如:https://push.hellyw.com/XXXXXXXX', ), @@ -336,7 +336,7 @@ export default { ], lark: [ { - label: 'larkKey', + label: 'fskey', tip: intl.get( '飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973', ), @@ -345,23 +345,23 @@ export default { ], email: [ { - label: 'emailService', + label: 'smtpService', tip: intl.get( '邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json', ), required: true, }, - { label: 'emailUser', tip: intl.get('邮箱地址'), required: true }, - { label: 'emailPass', tip: intl.get('SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定'), required: true }, + { label: 'smtpName', tip: intl.get('邮箱地址'), required: true }, + { label: 'smtpPassword', tip: intl.get('SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定'), required: true }, ], pushMe: [ { - label: 'pushMeKey', + label: 'pushmeKey', tip: intl.get('PushMe的Key,https://push.i-i.me/'), required: true, }, { - label: 'pushMeUrl', + label: 'pushmeUrl', tip: intl.get('自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口'), required: false, },