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

Function gobotNotify

function/sendNotify.js:1186–1227  ·  view source on GitHub ↗
(text, desp, time = 2100)

Source from the content-addressed store, hash-verified

1184}
1185
1186function gobotNotify(text, desp, time = 2100) {
1187 return new Promise((resolve) => {
1188 if (GOBOT_URL) {
1189 const options = {
1190 url: `${GOBOT_URL}?access_token=${GOBOT_TOKEN}&${GOBOT_QQ}`,
1191 json: {
1192 message: `${text}\n${desp}`
1193 },
1194 headers: {
1195 'Content-Type': 'application/json',
1196 },
1197 timeout,
1198 };
1199 setTimeout(() => {
1200 $.post(options, (err, resp, data) => {
1201 try {
1202 if (err) {
1203 console.log('发送go-cqhttp通知调用API失败!!\n');
1204 console.log(err);
1205 } else {
1206 data = JSON.parse(data);
1207 if (data.retcode === 0) {
1208 console.log('go-cqhttp发送通知消息成功🎉\n');
1209 } else if (data.retcode === 100) {
1210 console.log(`go-cqhttp发送通知消息异常: ${data.errmsg}\n`);
1211 } else {
1212 console.log(`go-cqhttp发送通知消息异常\n${JSON.stringify(data)}`);
1213 }
1214 }
1215 } catch (e) {
1216 $.logErr(e, resp);
1217 }
1218 finally {
1219 resolve(data);
1220 }
1221 });
1222 }, time);
1223 } else {
1224 resolve();
1225 }
1226 });
1227}
1228
1229function serverNotify(text, desp, time = 2100) {
1230 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