MCPcopy Create free account
hub / github.com/ClydeTime/Surge / handInGeneralTask

Function handInGeneralTask

Script/Task/xmly.js:807–865  ·  view source on GitHub ↗
(taskId)

Source from the content-addressed store, hash-verified

805}
806
807async function handInGeneralTask(taskId){
808 let headers = {
809 "Cookie": config.xm_cookie,
810 'Content-Type': `application/json`
811 }
812 let body = `{"aid":112,"taskId":${taskId}}`
813 let myRequest = {
814 url: `http://m.ximalaya.com/web-activity/task/v2/drawTaskAward`,
815 headers: headers,
816 body: body
817 }
818 return await $.http.post(myRequest).then(
819 (response) => {
820 body = JSON.parse(response.body)
821 if (body.ret == 0) {
822 if (body.data.status == 0) {
823 if ((taskId > 167 && taskId < 173) || taskId == 96 || taskId == 336) {
824 config.spec.num += 1
825 config.spec.time = format(startTime)
826 $.setdata(JSON.stringify(config.spec), name + "_spec")
827 $.log("- 交还特殊任务成功, 获得奖励点数")
828 } /* else {
829 config.gene.num += 1
830 config.gene.time = format(startTime)
831 $.setdata(JSON.stringify(config.gene), name + "_gene")
832 $.log("- 交还通用任务成功, 获得10点奖励")
833 } */
834 return true
835 } else if (body.data.status == 1) {
836 if ((taskId > 167 && taskId < 173) || taskId == 96 || taskId == 336) {
837 config.spec.num += 1
838 config.spec.time = format(startTime)
839 $.setdata(JSON.stringify(config.spec), name + "_spec")
840 $.log("- 此项特殊任务今日已交还")
841 } /* else {
842 config.gene.num += 1
843 config.gene.time = format(startTime)
844 $.setdata(JSON.stringify(config.gene), name + "_gene")
845 $.log("- 此项通用任务今日已交还")
846 } */
847 return true
848 } else if (body.data.status == -1) {
849 $.log("--- !!!此任务尚未完成,不能交还")
850 return false
851 } else {
852 $.log("--- !!!未知交还状态")
853 $.log(JSON.stringify(body.data))
854 return false
855 }
856 } else {
857 $.log("--- !!!交还任务失败")
858 return false
859 }
860 },(reason) => {
861 $.log("--- !!!交还通用任务失败")
862 return false
863 }
864 )

Callers 1

mainFunction · 0.85

Calls 6

formatFunction · 0.70
postMethod · 0.45
parseMethod · 0.45
setdataMethod · 0.45
stringifyMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected