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

Function BahamutAnswer

Bahamut/BahamutDailyBonus.js:256–286  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

254}
255
256function BahamutAnswer() { //动画疯答题
257
258 //未答题: {"game":"灌籃高手","question":"流川楓的號碼是下列何者?","a1":"7","a2":"11","a3":"23","a4":"59","userid":"GN32964174","token":"01092fe463ab36ab47cb298e229c4f8fb298e229cc260fa7baf"}
259 //已答题: {"error":1,"msg":"今日已經答過題目了,一天僅限一次機會"}
260 //未登录: {"error":1,"nologin":1,"msg":"請先登入"}
261
262 if ($.needAnswer === false || $.needAnswer === 'false') { //如果用户关闭动画疯答题
263 return; //退出答题函数
264 }
265 return $.http.get({ //使用get方获取题目 (Promise实例对象)
266 url: 'https://ani.gamer.com.tw/ajax/animeGetQuestion.php?t=' + Date.now(), //获取题目接口
267 headers: {} //请求头, 客户端将自动设置Cookie字段
268 })
269 .then(async (res) => { //网络请求成功的处理, 实例函数带有async关键字, 表示里面有异步操作
270 const r = JSON.parse(res.body); //解析响应体json为对象
271 if (r.token) { //如果有题目
272 $.log('', `✅获取动画疯题目成功`, ``, `🔶<${r.game}> ${r.question}`,
273 `1️⃣${r.a1}`, `2️⃣${r.a2}`, `3️⃣${r.a3}`, `4️⃣${r.a4}`); //打印日志
274 const article = await GetAanswerArticles(); //获取答案文章ID
275 const getAnswer = await StartSearchAnswers(article); //传入文章ID, 再从文章内获取答案
276 const sendAnswer = await StartBahamutAnswer(getAnswer, r.token); //传入答案和题目令牌, 开始答题
277 $.notifyMsg.push(`动画答题: ${sendAnswer}`); //答题后的结果添加到全局变量备用 (通知)
278 } else { //未获取到题目
279 throw new Error(r.msg || `获取题目失败`); //带上原因抛出异常
280 }
281 })
282 .catch(e => { //捕获异常, 打印日志
283 $.notifyMsg.push(`动画答题: ${e.message||e||`失败`}`); //添加到全局变量备用 (通知)
284 $.log('', `❌动画疯答题失败`, `❌${e.message||e}`); //打印日志
285 });
286}
287
288function GetAanswerArticles() { // 从blackxblue的小屋查询含答案的文章ID
289 $.log('', `🔶开始获取文章`); //打印日志

Callers 1

Calls 5

GetAanswerArticlesFunction · 0.85
StartSearchAnswersFunction · 0.85
StartBahamutAnswerFunction · 0.85
getMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected