| 10 | } |
| 11 | |
| 12 | export async function pushplus(title: string, content: string, template: string = 'html'): Promise<void> { |
| 13 | let token: string |
| 14 | for (let user of account) { |
| 15 | if (content.includes(decodeURIComponent(user.pt_pin)) && user.pushplus) { |
| 16 | token = user.pushplus |
| 17 | break |
| 18 | } |
| 19 | } |
| 20 | if (!token) { |
| 21 | console.log('no pushplus token') |
| 22 | return |
| 23 | } |
| 24 | let {data}: any = await axios.post('https://www.pushplus.plus/send', { |
| 25 | token: token, |
| 26 | title: title, |
| 27 | content: content, |
| 28 | template: template |
| 29 | }, { |
| 30 | headers: { |
| 31 | 'Content-Type': 'application/json' |
| 32 | } |
| 33 | }) |
| 34 | if (data.code === 200) { |
| 35 | console.log('pushplus发送成功') |
| 36 | } else { |
| 37 | console.log('pushplus发送失败', JSON.stringify(data)) |
| 38 | } |
| 39 | } |