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

Function doTask

jd_family.js:152–175  ·  view source on GitHub ↗
(taskId)

Source from the content-addressed store, hash-verified

150}
151
152function doTask(taskId) {
153 let body = `taskid=${taskId}`
154 return new Promise(resolve => {
155 $.get(taskUrl('family_task', body), async (err, resp, data) => {
156 try {
157 if (err) {
158 console.log(`${err},${jsonParse(resp.body)['message']}`)
159 console.log(`${$.name} API请求失败,请检查网路重试`)
160 } else {
161 data = JSON.parse(data.match(/query\((.*)\n/)[1])
162 if (data.ret === 0) {
163 console.log(`任务完成成功`)
164 } else {
165 console.log(`任务完成失败,原因未知`)
166 }
167 }
168 } catch (e) {
169 $.logErr(e, resp)
170 } finally {
171 resolve(data);
172 }
173 })
174 })
175}
176
177function taskUrl(function_id, body = '') {
178 body = `activeid=${$.info.activeId}&token=${$.info.actToken}&sceneval=2&shareid=&t=${Date.now()}&_=${new Date().getTime()}&callback=query&${body}`

Callers 1

getUserInfoFunction · 0.70

Calls 5

taskUrlFunction · 0.70
jsonParseFunction · 0.70
getMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected