fix: 更改酷推信息格式

This commit is contained in:
shanmite 2021-03-19 18:04:58 +08:00
parent 3c55ae6a70
commit cb0788489b
4 changed files with 8 additions and 8 deletions

View File

@ -6,6 +6,7 @@ on:
schedule:
- cron: '0 */2 * * *'
env:
MY_CONFIG: ${{ secrets.MY_CONFIG }}
PAT: ${{ secrets.PAT }}
SCKEY: ${{ secrets.SCKEY }}
SENDKEY: ${{ secrets.SENDKEY }}

View File

@ -6,6 +6,7 @@ on:
schedule:
- cron: '0 17 1 * *'
env:
MY_CONFIG: ${{ secrets.MY_CONFIG }}
CLEAR: ${{ secrets.CLEAR }}
PAT: ${{ secrets.PAT }}
SCKEY: ${{ secrets.SCKEY }}

View File

@ -33,7 +33,7 @@
* @property {RequestConfig} [config] 设置
* @property {Proxy} [proxy] 代理
* @property {Object.<string, string|number>} [query] 查询选项
* @property {Object.<string, string|number>} [contents] 内容
* @property {Object.<string, string|number> | string} [contents] 内容
* @property {HttpHeaders} [headers] 请求头
* @property {SuccessCb} success 成功回调
* @property {FailureCb} failure 失败回调
@ -79,7 +79,7 @@ function HttpRequest(detail) {
};
if (!headers["user-agent"]) headers["user-agent"] = DEFAULT_UA;
if (query) options.path += (thisURL.search ? '&' : '?') + stringify(query);
if (contents) options.headers['content-length'] = Buffer.byteLength(content, 'utf-8').toString();
if (content) options.headers['content-length'] = Buffer.byteLength(content, 'utf-8').toString();
if (proxy) {
options.headers.host = thisURL.host;
[options.hostname, options.port] = proxy.host ?
@ -147,6 +147,7 @@ function HttpRequest(detail) {
*/
function formatContents(type, contents) {
if (/application\/json/i.test(type)) return JSON.stringify(contents);
if (/text\/plain/i.test(type)) return contents;
if (contents) return stringify(contents)
return contents;
}

View File

@ -263,16 +263,13 @@ function coolPush(text, desp) {
HttpRequest({
method: 'POST',
url: `https://push.xuthus.cc/${QQ_MODE}/${QQ_SKEY}`,
contents: {
title: text,
desc: desp
},
contents: `${text}\n${desp}`,
config: {
retry: false
},
headers: {
accept: 'application/json, text/plain, */*',
'content-type': 'application/json'
"content-type": "text/plain",
},
success: res => {
try {
@ -280,7 +277,7 @@ function coolPush(text, desp) {
if (data.code === 200) {
console.log(`酷推发送${pushMode(QQ_MODE)}通知消息成功\n`)
} else if (data.code === 400) {
console.log(`QQ酷推(Cool Push)发送${pushMode(QQ_MODE)}推送失败:${data.msg}\n`)
console.log(`QQ酷推(Cool Push)发送${pushMode(QQ_MODE)}推送失败:${data}\n`)
} else {
console.log(`酷推推送异常: ${data.msg}`);
}