-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
更换PushPlus服务为WxPusher #18
base: main
Are you sure you want to change the base?
更换PushPlus服务为WxPusher #18
Conversation
@@ -31,16 +31,17 @@ const glados = async () => { | |||
} | |||
|
|||
const notify = async (contents) => { | |||
const token = process.env.NOTIFY | |||
if (!token || !contents) return | |||
await fetch(`https://www.pushplus.plus/send`, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
别直接删除,还有人在用
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议的写法:
用一个特殊标记, 区分是否使用 wxpusher, 如果没有标记, 则使用默认方式
const notify = async (contents) => {
const token = process.env.NOTIFY
if (!token || !contents) return
if (token.startsWith('wxpusher:') {
const [_, appToken, uids] = token.split(':')
await fetch(`https://wxpusher.zjiecode.com/api/send/message`, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
appToken,
summary: contents[0],
content: contents.join('<br>'),
contentType: 3,
uids: uids.split(','),
}),
})
} else {
await fetch(`https://www.pushplus.plus/send`, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
token,
title: contents[0],
content: contents.join('<br>'),
template: 'markdown',
}),
})
}
}
配置格式: wxpusher:token:uids
'content': contents.join('<br>'), | ||
'summary': 'GLADOS:' + contents[0], | ||
'contentType': 3, | ||
'uids': eval(process.env.WXPusherUIDS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
别用 eval, 用 split, 或者 JSON.parse
需要额外配置 “WXPusherAppToken”、"WXPusherUIDS"两个Secret