Skip to content
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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

NinePointEightByte
Copy link

需要额外配置 “WXPusherAppToken”、"WXPusherUIDS"两个Secret

@@ -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`, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

别直接删除,还有人在用

Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

别用 eval, 用 split, 或者 JSON.parse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants