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

Function GetAanswerArticles

Bahamut/BahamutDailyBonus.js:288–305  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

286}
287
288function GetAanswerArticles() { // 从blackxblue的小屋查询含答案的文章ID
289 $.log('', `🔶开始获取文章`); //打印日志
290 return $.http.get({ //使用get方法获取文章ID (Promise实例对象)
291 url: 'https://api.gamer.com.tw/mobile_app/bahamut/v1/home.php?owner=blackXblue&page=1', //获取文章ID接口
292 headers: {}
293 })
294 .then((res) => { //网络请求成功后的处理
295 const body = JSON.parse(res.body); //解析响应体json为对象
296 const tDate = $.time('MM/dd'); //返回今日日期
297 const title = (body.creation || []).filter(t => t.title.includes(tDate)); //过滤后返回今日答案文章
298 if (title.length && title[0].sn) { //如果有答案文章
299 $.log('', `✅获取文章成功 (${title[0].sn})`); //打印日志
300 return title[0].sn; //返回文章ID
301 } else { //否则带上原因抛出异常, 被调用该函数时的catch捕获
302 throw new Error('今日答案未发表');
303 }
304 })
305}
306
307function StartSearchAnswers(id) { //获取文章内答案
308 $.log('', `🔶开始获取答案`); //打印日志

Callers 1

BahamutAnswerFunction · 0.85

Calls 3

logMethod · 0.45
getMethod · 0.45
timeMethod · 0.45

Tested by

no test coverage detected