| 120 | } |
| 121 | |
| 122 | function GetAuth(body, data) { |
| 123 | if (body.ticket && body.uid) { |
| 124 | if (!data.account || !data.account[body.uid]) { |
| 125 | notifyMsg.push(`账号: ${body.uid}\n写入授权成功!`); |
| 126 | } else { |
| 127 | $.info(`账号: ${body.uid}\n更新授权成功!`); |
| 128 | } |
| 129 | data.account = { ...data.account, ...{ [body.uid]: { auth: body.ticket } } }; |
| 130 | } else { |
| 131 | $.error(`写入授权失败, 授权值缺失.`) |
| 132 | } |
| 133 | return $.setjson(data, $.name); |
| 134 | } |
| 135 | |
| 136 | //Bark APP notify |
| 137 | async function BarkNotify(c, k, t, b) { for (let i = 0; i < 3; i++) { c.log(`🔷Bark notify >> Start push (${i + 1})`); const s = await new Promise((n) => { c.post({ url: 'https://api.day.app/push', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title: t, body: b, device_key: k, ext_params: { group: t } }) }, (e, r, d) => r && r.status == 200 ? n(1) : n(d || e)) }); if (s === 1) { c.log('✅Push success!'); break } else { c.log(`❌Push failed! >> ${s.message || s}`) } } }; |