Skip to content

Commit

Permalink
fix: 防止kuroApi方法重名
Browse files Browse the repository at this point in the history
  • Loading branch information
TomyJan committed Jul 28, 2023
1 parent 886c3e8 commit f1ea940
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
24 changes: 12 additions & 12 deletions model/bbsTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,23 @@ export async function doBBSDailyTask(uin, kuro_uid) {
// 开始尝试 2 次取帖子列表, 获取不到就不浏览和点赞
tryAgain = true
tryTimes = 0
let rsp_list = ''
let rsp_forumList = ''
do {
rsp_list = await kuroapi.list(kuro_uid, { forumId: 2, gameId: 2 }) // 默认获取推荐板块
logger.mark('rsp_list ' + JSON.stringify(rsp_list))
rsp_forumList = await kuroapi.forumList(kuro_uid, { forumId: 2, gameId: 2 }) // 默认获取推荐板块
logger.mark('rsp_forumList ' + JSON.stringify(rsp_forumList))

if (tryTimes++ >= 2 || typeof rsp_list !== 'string') tryAgain = false
if (tryTimes++ >= 2 || typeof rsp_forumList !== 'string') tryAgain = false

if (!tryAgain) {
if (typeof rsp_list !== 'string' && rsp_list.code === 200) break
if (typeof rsp_forumList !== 'string' && rsp_forumList.code === 200) break
doBBSDailyTaskRet += `获取失败: ${
rsp_list.msg || rsp_list
rsp_forumList.msg || rsp_forumList
}\n论坛点赞: 已取消\n` // 直接处理完返回值
rsp_list = ''
rsp_forumList = ''
} else await sleepAsync(getRandomInt(200, 400))
} while (tryAgain)

if (rsp_list) {
if (rsp_forumList) {
await sleepAsync(getRandomInt(500, 2000))
// 获取到帖子就浏览点赞, 获取不到上面已经返回错误了
// 开始尝试 6 次浏览帖子
Expand All @@ -152,7 +152,7 @@ export async function doBBSDailyTask(uin, kuro_uid) {
let succCount = 0
do {
let rsp_getPostDetail = await kuroapi.getPostDetail(kuro_uid, {
postId: rsp_list.data.postList[tryTimes].postId,
postId: rsp_forumList.data.postList[tryTimes].postId,
})
logger.mark('rsp_getPostDetail ' + JSON.stringify(rsp_getPostDetail))

Expand All @@ -176,9 +176,9 @@ export async function doBBSDailyTask(uin, kuro_uid) {
operateType: 1,
postCommentId: 0,
postCommentReplyId: 0,
postId: rsp_list.data.postList[tryTimes].postId,
postType: rsp_list.data.postList[tryTimes].postType,
toUserId: rsp_list.data.postList[tryTimes].userId,
postId: rsp_forumList.data.postList[tryTimes].postId,
postType: rsp_forumList.data.postList[tryTimes].postType,
toUserId: rsp_forumList.data.postList[tryTimes].userId,
})
logger.mark('rsp_like ' + JSON.stringify(rsp_like))

Expand Down
4 changes: 2 additions & 2 deletions model/kuroApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ export default class kuroApi {
* @param {object} data 传入 data.forumId 板块 id, data.gameId 游戏 id
* @returns {JSON|string} code=200 时接口返回的原始 json 或者报错信息
*/
async list(kuroUid, data) {
async forumList(kuroUid, data) {
data.pageIndex = 1
data.pageSize = 20
data.searchType = 2
data.timeType = 0
data.topicId = 0
return this.getData('list', kuroUid, data)
return this.getData('forumList', kuroUid, data)
}

/**
Expand Down
4 changes: 2 additions & 2 deletions model/kuroApiHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default class kuroApiHandler {
url: `${this.kuroApiUrl}/user/signIn`,
body: `gameId=${data.gameId}`,
},
list: {
forumList: {
//取帖子列表
url: `${this.kuroApiUrl}/forum/list`,
body: `forumId=${data.forumId}&gameId=${data.gameId}&pageIndex=${data.pageIndex}&pageSize=${data.pageSize}&searchType=${data.searchType}&timeType=${data.timeType}&topicId=${data.topicId}`,
Expand Down Expand Up @@ -199,7 +199,7 @@ export default class kuroApiHandler {
token: token,
}
}
if (!['list', 'findRoleList', 'roleList'].includes(ApiName)) {
if (!['forumList', 'findRoleList', 'roleList'].includes(ApiName)) {
// 除了上面几个其他都有 distinct_id
headers = {
...headers,
Expand Down

0 comments on commit f1ea940

Please sign in to comment.