(text, desp)
| 1148 | } |
| 1149 | |
| 1150 | function gotifyNotify(text, desp) { |
| 1151 | return new Promise((resolve) => { |
| 1152 | if (GOTIFY_URL && GOTIFY_TOKEN) { |
| 1153 | const options = { |
| 1154 | url: `${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}`, |
| 1155 | body: `title=${encodeURIComponent(text)}&message=${encodeURIComponent(desp)}&priority=${GOTIFY_PRIORITY}`, |
| 1156 | headers: { |
| 1157 | 'Content-Type': 'application/x-www-form-urlencoded', |
| 1158 | } |
| 1159 | }; |
| 1160 | $.post(options, (err, resp, data) => { |
| 1161 | try { |
| 1162 | if (err) { |
| 1163 | console.log('gotify发送通知调用API失败!!\n'); |
| 1164 | console.log(err); |
| 1165 | } else { |
| 1166 | data = JSON.parse(data); |
| 1167 | if (data.id) { |
| 1168 | console.log('gotify发送通知消息成功🎉\n'); |
| 1169 | } else { |
| 1170 | console.log(`${data.message}\n`); |
| 1171 | } |
| 1172 | } |
| 1173 | } catch (e) { |
| 1174 | $.logErr(e, resp); |
| 1175 | } |
| 1176 | finally { |
| 1177 | resolve(); |
| 1178 | } |
| 1179 | }); |
| 1180 | } else { |
| 1181 | resolve(); |
| 1182 | } |
| 1183 | }); |
| 1184 | } |
| 1185 | |
| 1186 | function gobotNotify(text, desp, time = 2100) { |
| 1187 | return new Promise((resolve) => { |
no test coverage detected