MCPcopy Create free account
hub / github.com/6dylan6/jdpro / gotifyNotify

Function gotifyNotify

function/sendNotify.js:1150–1184  ·  view source on GitHub ↗
(text, desp)

Source from the content-addressed store, hash-verified

1148}
1149
1150function 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
1186function gobotNotify(text, desp, time = 2100) {
1187 return new Promise((resolve) => {

Callers 1

sendNotifyFunction · 0.70

Calls 3

postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected