twikoo-func 1.4.14 → 1.4.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +48 -8
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Twikoo cloudbase function v1.4.
|
|
2
|
+
* Twikoo cloudbase function v1.4.18
|
|
3
3
|
* (c) 2020-present iMaeGoo
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -31,7 +31,7 @@ const window = new JSDOM('').window
|
|
|
31
31
|
const DOMPurify = createDOMPurify(window)
|
|
32
32
|
|
|
33
33
|
// 常量 / constants
|
|
34
|
-
const VERSION = '1.4.
|
|
34
|
+
const VERSION = '1.4.18'
|
|
35
35
|
const RES_CODE = {
|
|
36
36
|
SUCCESS: 0,
|
|
37
37
|
FAIL: 1000,
|
|
@@ -880,7 +880,9 @@ async function sendNotice (comment) {
|
|
|
880
880
|
noticePushPlus(comment),
|
|
881
881
|
noticeWeComPush(comment),
|
|
882
882
|
noticeDingTalkHook(comment),
|
|
883
|
-
|
|
883
|
+
noticePushdeer(comment),
|
|
884
|
+
noticeQQ(comment),
|
|
885
|
+
noticeQQAPI(comment)
|
|
884
886
|
]).catch(err => {
|
|
885
887
|
console.error('邮件通知异常:', err)
|
|
886
888
|
})
|
|
@@ -931,7 +933,8 @@ async function noticeMaster (comment) {
|
|
|
931
933
|
'QM_SENDKEY',
|
|
932
934
|
'PUSH_PLUS_TOKEN',
|
|
933
935
|
'WECOM_API_URL',
|
|
934
|
-
'DINGTALK_WEBHOOK_URL'
|
|
936
|
+
'DINGTALK_WEBHOOK_URL',
|
|
937
|
+
'PUSHDEER_KEY'
|
|
935
938
|
]
|
|
936
939
|
// 判断是否存在即时消息推送配置
|
|
937
940
|
const hasIMPushConfig = IM_PUSH_CONFIGS.some(item => !!config[item])
|
|
@@ -1017,7 +1020,7 @@ async function noticePushPlus (comment) {
|
|
|
1017
1020
|
return
|
|
1018
1021
|
}
|
|
1019
1022
|
if (config.BLOGGER_EMAIL === comment.mail) return
|
|
1020
|
-
const pushContent = getIMPushContent(comment)
|
|
1023
|
+
const pushContent = getIMPushContent(comment, { withUrl: false, html: true })
|
|
1021
1024
|
const ppApiUrl = 'http://pushplus.hxtrip.com/send'
|
|
1022
1025
|
const ppApiParam = {
|
|
1023
1026
|
token: config.PUSH_PLUS_TOKEN,
|
|
@@ -1062,7 +1065,7 @@ async function noticeQQ (comment) {
|
|
|
1062
1065
|
return
|
|
1063
1066
|
}
|
|
1064
1067
|
if (config.BLOGGER_EMAIL === comment.mail) return
|
|
1065
|
-
const pushContent = getIMPushContent(comment)
|
|
1068
|
+
const pushContent = getIMPushContent(comment, { withUrl: false })
|
|
1066
1069
|
const qmApiUrl = 'https://qmsg.zendee.cn'
|
|
1067
1070
|
const qmApiParam = {
|
|
1068
1071
|
msg: pushContent.subject + '\n' + pushContent.content.replace(/<br>/g, '\n')
|
|
@@ -1073,8 +1076,35 @@ async function noticeQQ (comment) {
|
|
|
1073
1076
|
console.log('QQ通知结果:', sendResult)
|
|
1074
1077
|
}
|
|
1075
1078
|
|
|
1079
|
+
async function noticePushdeer (comment) {
|
|
1080
|
+
if (!config.PUSHDEER_KEY) return
|
|
1081
|
+
if (config.BLOGGER_EMAIL === comment.mail) return
|
|
1082
|
+
const pushContent = getIMPushContent(comment, { markdown: true })
|
|
1083
|
+
const sendResult = await axios.post('https://api2.pushdeer.com/message/push', {
|
|
1084
|
+
pushkey: config.PUSHDEER_KEY,
|
|
1085
|
+
text: pushContent.subject,
|
|
1086
|
+
desp: pushContent.content
|
|
1087
|
+
})
|
|
1088
|
+
console.log('Pushdeer 通知结果:', sendResult)
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
// QQ私有化API通知
|
|
1092
|
+
async function noticeQQAPI (comment) {
|
|
1093
|
+
if (!config.QQ_API) {
|
|
1094
|
+
console.log('没有配置QQ私有化api,放弃QQ通知')
|
|
1095
|
+
return
|
|
1096
|
+
}
|
|
1097
|
+
if (config.BLOGGER_EMAIL === comment.mail) return
|
|
1098
|
+
const pushContent = getIMPushContent(comment)
|
|
1099
|
+
const qqApiParam = {
|
|
1100
|
+
message: pushContent.subject + '\n' + pushContent.content.replace(/<br>/g, '\n')
|
|
1101
|
+
}
|
|
1102
|
+
const sendResult = await axios.post(`${config.QQ_API}`, qs.stringify(qqApiParam))
|
|
1103
|
+
console.log('QQ私有化api通知结果:', sendResult)
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1076
1106
|
// 即时消息推送内容获取
|
|
1077
|
-
function getIMPushContent (comment) {
|
|
1107
|
+
function getIMPushContent (comment, { withUrl = true, markdown = false, html = false } = {}) {
|
|
1078
1108
|
const SITE_NAME = config.SITE_NAME
|
|
1079
1109
|
const NICK = comment.nick
|
|
1080
1110
|
const MAIL = comment.mail
|
|
@@ -1083,7 +1113,17 @@ function getIMPushContent (comment) {
|
|
|
1083
1113
|
const SITE_URL = config.SITE_URL
|
|
1084
1114
|
const POST_URL = appendHashToUrl(comment.href || SITE_URL + comment.url, comment.id)
|
|
1085
1115
|
const subject = config.MAIL_SUBJECT_ADMIN || `${SITE_NAME}有新评论了`
|
|
1086
|
-
|
|
1116
|
+
let content = `评论人:${NICK}(${MAIL})<br>评论人IP:${IP}<br>评论内容:${COMMENT}<br>`
|
|
1117
|
+
// Qmsg 会过滤带网址的推送消息,所以不能带网址
|
|
1118
|
+
if (withUrl) {
|
|
1119
|
+
content += `原文链接:${markdown ? `[${POST_URL}](${POST_URL})` : POST_URL}`
|
|
1120
|
+
}
|
|
1121
|
+
if (html) {
|
|
1122
|
+
content += `原文链接:<a href="${POST_URL}" rel="nofollow">${POST_URL}</a>`
|
|
1123
|
+
}
|
|
1124
|
+
if (markdown) {
|
|
1125
|
+
content = content.replace(/<br>/g, '\n\n')
|
|
1126
|
+
}
|
|
1087
1127
|
return {
|
|
1088
1128
|
subject,
|
|
1089
1129
|
content
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twikoo-func",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.18",
|
|
4
4
|
"description": "A simple comment system based on Tencent CloudBase (tcb).",
|
|
5
5
|
"author": "imaegoo <hello@imaegoo.com> (https://github.com/imaegoo)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"crypto-js": "^4.0.0",
|
|
22
22
|
"dompurify": "^2.2.6",
|
|
23
23
|
"jsdom": "^16.4.0",
|
|
24
|
-
"marked": "^
|
|
24
|
+
"marked": "^4.0.12",
|
|
25
25
|
"nodemailer": "^6.4.17",
|
|
26
26
|
"querystring": "^0.2.0",
|
|
27
27
|
"tencentcloud-sdk-nodejs": "^4.0.65",
|