MCPcopy Create free account
hub / github.com/NobyDa/Script / StartBahamutAnswer

Function StartBahamutAnswer

Bahamut/BahamutDailyBonus.js:325–349  ·  view source on GitHub ↗
(answer, token)

Source from the content-addressed store, hash-verified

323}
324
325function StartBahamutAnswer(answer, token) { //动画疯答题
326
327 //答题正确: {"ok":1,"gift":"恭喜您得到:300 巴幣"}
328 //答题错误: {"error":1,"msg":"答題錯誤"}
329 //令牌过期: {"error":1,"msg":"很抱歉!本題目已超過時效!"}
330 //已答题: {"error":1,"msg":"今日已經答過題目了,一天僅限一次機會"}
331 //未登录: {"error":1,"nologin":1,"msg":"請先登入"}
332
333 $.log('', `🔶开始答题`); //打印日志
334 return $.http.post({ //使用post方法提交答案 (Promise实例对象)
335 url: 'https://ani.gamer.com.tw/ajax/animeAnsQuestion.php', //提交答案接口
336 headers: {}, //请求头, 客户端将自动设置Cookie字段
337 body: `token=${token}&ans=${answer}&t=${Date.now()}`, //请求体带上答案和答案令牌
338 })
339 .then((res) => { //网络请求成功后的处理
340 const body = JSON.parse(res.body); //解析响应体json为对象
341 if (body.ok) { //如果答题成功
342 $.log('', `✅${body.gift}`); //打印奖励日志
343 return body.gift; //返回奖励内容
344 } else { //否则答题失败
345 const failMsg = body.error ? body.error.message : null; //提取签到失败原因
346 throw new Error(body.msg || failMsg || '未知'); //否则带上原因抛出异常, 被调用该函数时的catch捕获
347 }
348 })
349}
350
351//Bark APP notify
352async function BarkNotify(c,k,t,b){for(let i=0;i<3;i++){console.log(`🔷Bark notify >> Start push (${i+1})`);const s=await new Promise((n)=>{c.post({url:'https://api.day.app/push',headers:{'Content-Type':'application/json'},body:JSON.stringify({title:t,body:b,device_key:k,ext_params:{group:t}})},(e,r,d)=>r&&r.status==200?n(1):n(d||e))});if(s===1){console.log('✅Push success!');break}else{console.log(`❌Push failed! >> ${s.message||s}`)}}};

Callers 1

BahamutAnswerFunction · 0.85

Calls 2

logMethod · 0.45
postMethod · 0.45

Tested by

no test coverage detected