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

Function answer

activity/jd_immortal_answer.js:302–342  ·  view source on GitHub ↗
(body = {})

Source from the content-addressed store, hash-verified

300}
301
302function answer(body = {}) {
303 return new Promise((resolve) => {
304 $.get(taskUrl('mcxhd_brandcity_answerQuestion', {"costTime": 1, ...body}), async (err, resp, data) => {
305 try {
306 if (err) {
307 console.log(`${JSON.stringify(err)}`)
308 console.log(`${$.name} API请求失败,请检查网路重试`)
309 } else {
310 data = JSON.parse(data);
311 // console.log(data)
312 if (data && data['retCode'] === "200") {
313 if (data.result.isCorrect) {
314 console.log(`您选对啦!获得积分${data.result.score},本次答题共计获得${data.result.totalScore}分`)
315 $.earn += parseInt(data.result.score)
316 $.question = {
317 ...$.question,
318 correct: $.option
319 }
320 } else {
321 let correct = $.question.options.filter(vo => vo.optionId === data.result.correctOptionId)[0]
322 console.log(`您选错啦~正确答案是:${correct.optionDesc}`)
323 $.question = {
324 ...$.question,
325 correct: correct
326 }
327 }
328 if (data.result.isLastQuestion) {
329 console.log(`答题完成`)
330 }
331 } else {
332 console.log(`答题失败`)
333 }
334 }
335 } catch (e) {
336 $.logErr(e, resp);
337 } finally {
338 resolve();
339 }
340 })
341 })
342}
343
344function bing(str) {
345 return new Promise(resolve => {

Callers 1

getQuestionsFunction · 0.85

Calls 4

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

Tested by

no test coverage detected