From 093b627bc1ec469b7223be7d48110f7a739694a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=9F=E6=84=8F?= Date: Fri, 19 Jul 2024 10:25:26 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E5=AE=8C=E5=96=84QMsg=E9=85=B1=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=20(#25)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [add] 完善QMsg酱功能 - 支持私有化部署自定义url - 支持指定接收者 - 支持接收者为群聊 Signed-off-by: 钟意 * [add] 完善QMsg酱功能 - 支持私有化部署自定义url - 支持指定接收者 - 支持接收者为群聊 Signed-off-by: 钟意 --------- Signed-off-by: 钟意 --- src/index.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 38b287d..3d3346e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,6 +35,15 @@ export interface NoticeOptions { url?: string; verifyPay?: boolean; }; + /** + * QMsg酱通知方式的参数配置 + */ + qmsg?: { + qq?: string; + url?: string; + group?: boolean; + bot?: string; + }; dingtalk?: { /** * 消息类型,目前支持 text、markdown。不设置,默认为 text。 @@ -103,7 +112,7 @@ function removeUrlAndIp(content: string) { */ async function noticeQmsg(options: CommonOptions) { checkParameters(options, ['token', 'content']); - const url = 'https://qmsg.zendee.cn'; + const url = options?.options?.qmsg?.url ||'https://qmsg.zendee.cn'; let msg = getTxt(options.content); if (options.title) { msg = `${options.title}\n${msg}`; @@ -111,7 +120,12 @@ async function noticeQmsg(options: CommonOptions) { // 移除网址和 IP 以避免 Qmsg 酱被 Tencent 封号 msg = removeUrlAndIp(msg); const param = new URLSearchParams({ msg }); - const response = await axios.post(`${url}/send/${options.token}`, param.toString(), { + const qq = options?.options?.qmsg?.qq || false; + qq?param.append('qq', qq):null; + const bot = options?.options?.qmsg?.bot || false; + bot?param.append('bot', bot):null; + const group = options?.options?.qmsg?.group || false; + const response = await axios.post(`${url}/${group?'group':'send'}/${options.token}`, param.toString(), { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, }); return response.data;