diff --git a/src/index.ts b/src/index.ts index 126e3dc..7bad4d3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -136,6 +136,12 @@ app.get('/comments/account', handler => commentsAccountGetHandler(handler), { description: 'The page you want to get, starts from `0`. Default is `0`.' }) + ), + amount: t.Optional( + t.String({ + description: + 'The amount of comments you want to get. Default is `10`. Range is `1`-`100`.' + }) ) }) }) @@ -154,6 +160,17 @@ app.get( description: 'The page you want to get, starts from `0`. Default is `0`.' }) + ), + amount: t.Optional( + t.String({ + description: + 'The amount of comments you want to get. Default is `10`. Range is `1`-`100`.' + }) + ), + mode: t.Optional( + t.Union([t.Literal('recent'), t.Literal('top')], { + description: 'Default is `recent`.' + }) ) }) } @@ -171,6 +188,12 @@ app.get('/comments/level', handler => commentsLevelGetHandler(handler), { 'The page you want to get, starts from `0`. Default is `0`.' }) ), + amount: t.Optional( + t.String({ + description: + 'The amount of comments you want to get. Default is `10`. Range is `1`-`100`.' + }) + ), mode: t.Optional( t.Union([t.Literal('recent'), t.Literal('top')], { description: 'Default is `recent`.' diff --git a/src/routes/comments/account/get.ts b/src/routes/comments/account/get.ts index 8b55b45..f7bed57 100644 --- a/src/routes/comments/account/get.ts +++ b/src/routes/comments/account/get.ts @@ -5,6 +5,7 @@ import { Context } from 'elysia' export const handler = async (handler: Context) => { const id = handler.query.id const page = handler.query.page + const amount = handler.query.amount const request = await axios.post( 'https://www.boomlings.com/database/getGJAccountComments20.php', @@ -13,6 +14,7 @@ export const handler = async (handler: Context) => { binaryVersion: '45', accountID: id, page: page ?? '0', + count: amount ?? '10', secret: 'Wmfd2893gb7' }), { @@ -33,12 +35,19 @@ export const handler = async (handler: Context) => { responseSplit.map(item => { const commentInfo = item[0] - return { + const data = { id: +commentInfo['6'], - content: atob(commentInfo['2']), + content: commentInfo['2'], + decodeFailed: false, likes: +commentInfo['4'], date: commentInfo['9'] + ' ago' } + try { + data.content = atob(data.content) + } catch { + data.decodeFailed = true + } + return data }) ) } diff --git a/src/routes/comments/account/history/get.ts b/src/routes/comments/account/history/get.ts index 56ce732..75b0e22 100644 --- a/src/routes/comments/account/history/get.ts +++ b/src/routes/comments/account/history/get.ts @@ -5,6 +5,8 @@ import { Context } from 'elysia' export const handler = async (handler: Context) => { const id = handler.query.id const page = handler.query.page + const mode = handler.query.mode + const amount = handler.query.amount const request = await axios.post( 'https://www.boomlings.com/database/getGJCommentHistory.php', @@ -13,8 +15,9 @@ export const handler = async (handler: Context) => { binaryVersion: '45', page: page ?? '0', secret: 'Wmfd2893gb7', - mode: '1', - userID: id + mode: mode ? (mode == 'recent' ? '0' : '1') : '0', //Don't worry about it + userID: id, + count: amount ?? '10' }), { headers: { @@ -35,10 +38,11 @@ export const handler = async (handler: Context) => { const commentInfo = item[0] const accountInfo = item[1] - return { + const data = { id: +commentInfo['6'], levelId: +commentInfo['1'], - content: atob(commentInfo['2']), + content: commentInfo['2'], + decodeFailed: false, likes: +commentInfo['4'], date: commentInfo['9'] + ' ago', commentColor: commentInfo['12'] @@ -61,6 +65,12 @@ export const handler = async (handler: Context) => { } } } + try { + data.content = atob(data.content) + } catch { + data.decodeFailed = true + } + return data }) ) } diff --git a/src/routes/comments/level/get.ts b/src/routes/comments/level/get.ts index 489d645..d219f8c 100644 --- a/src/routes/comments/level/get.ts +++ b/src/routes/comments/level/get.ts @@ -6,21 +6,19 @@ export const handler = async (handler: Context) => { const id = handler.query.id const page = handler.query.page const mode = handler.query.mode + const amount = handler.query.amount const request = await axios.post( 'https://www.boomlings.com/database/getGJComments21.php', new URLSearchParams({ gameVersion: '22', binaryVersion: '45', - udid: 'BEA53432-326F-4D39-91D7-2B51B849825E', - uuid: '241138636', - accountID: '28945106', - gjp2: '836845372d7a726b35f627bcc491d4e122782c17', page: page ?? '0', total: '0', secret: 'Wmfd2893gb7', mode: mode ? (mode == 'recent' ? '0' : '1') : '0', //Don't worry about it - levelID: id + levelID: id, + count: amount ?? '10' }), { headers: { @@ -41,9 +39,10 @@ export const handler = async (handler: Context) => { const commentInfo = item[0] const accountInfo = item[1] - return { + const data = { id: +commentInfo['6'], - content: atob(commentInfo['2']), + content: commentInfo['2'], + decodeFailed: false, likes: +commentInfo['4'], date: commentInfo['9'] + ' ago', commentColor: commentInfo['12'] @@ -66,6 +65,12 @@ export const handler = async (handler: Context) => { } } } + try { + data.content = atob(data.content) + } catch { + data.decodeFailed = true + } + return data }) ) }