MCPcopy Create free account
hub / github.com/Semporia/Scripts / goCQhttp

Function goCQhttp

sendNotify.js:182–215  ·  view source on GitHub ↗
(text, desp)

Source from the content-addressed store, hash-verified

180}
181
182function goCQhttp(text, desp) {
183 if (go_cqhttp_url && go_cqhttp_qq && go_cqhttp_method) {
184 let msg = (text + '\n' + desp).replace("\n\n仅供用于学习", '');
185
186 let recv_id = ''
187 if (go_cqhttp_method === 'send_private_msg') {
188 recv_id = 'user_id'
189 } else if (go_cqhttp_method === 'send_group_msg') {
190 recv_id = 'group_id'
191 }
192
193 return new Promise(resolve => {
194 $.get({
195 url: `http://${go_cqhttp_url}/${go_cqhttp_method}?${recv_id}=${go_cqhttp_qq}&message=${escape(msg)}`
196 }, (err, resp, data) => {
197 if (!err) {
198 try {
199 // console.log(data);
200 data = JSON.parse(data);
201 if (data.retcode === 0 && data.status === 'ok') {
202 console.log('go-cqhttp发送通知消息成功🎉\n')
203 } else {
204 console.log(`go-cqhttp发送通知消息异常\n${JSON.stringify(data)}`)
205 }
206 } catch (e) {
207 $.logErr(e, resp)
208 } finally {
209 resolve(200)
210 }
211 }
212 })
213 })
214 }
215}
216
217function serverNotify(text, desp, time = 2100) {
218 return new Promise(resolve => {

Callers 1

sendNotifyFunction · 0.85

Calls 3

getMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected