Add getting comments
This commit is contained in:
8 files changed
+340
-5
No files matched your search
@@ -14,6 +14,9 @@ This is very early in development and will not be finished for a long time likel
|
|||||||
- [x] Get classic level scores
|
- [x] Get classic level scores
|
||||||
- [x] Get plat level scores
|
- [x] Get plat level scores
|
||||||
- [x] Get daily/weekly level
|
- [x] Get daily/weekly level
|
||||||
|
- [x] Get level comments
|
||||||
|
- [x] Get account comments
|
||||||
|
- [x] Get account comment history
|
||||||
- [ ] Get event level
|
- [ ] Get event level
|
||||||
- [ ] Get Levels List
|
- [ ] Get Levels List
|
||||||
- [ ] Get save data
|
- [ ] Get save data
|
||||||
@@ -22,9 +25,6 @@ This is very early in development and will not be finished for a long time likel
|
|||||||
- [ ] Get user (profile?)
|
- [ ] Get user (profile?)
|
||||||
- [ ] Get user info
|
- [ ] Get user info
|
||||||
- [ ] Get messages (account?)
|
- [ ] Get messages (account?)
|
||||||
- [ ] Get comments
|
|
||||||
- [ ] Get comment history
|
|
||||||
- [ ] Get account comments
|
|
||||||
- [ ] Get account friend requests
|
- [ ] Get account friend requests
|
||||||
- [ ] Get user list (friends list?)
|
- [ ] Get user list (friends list?)
|
||||||
- [ ] Get rewards (chests?)
|
- [ ] Get rewards (chests?)
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import axios from 'axios'
|
||||||
|
import { jsonResponse, splitGd } from '../../../lib/util'
|
||||||
|
|
||||||
|
export const handler = async () => {
|
||||||
|
const request = await axios.post(
|
||||||
|
'https://www.boomlings.com/database/getGJMapPacks21.php',
|
||||||
|
new URLSearchParams({
|
||||||
|
gameVersion: '22',
|
||||||
|
binaryVersion: '45',
|
||||||
|
count: '250',
|
||||||
|
page: '0',
|
||||||
|
secret: 'Wmfd2893gb7'
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'User-Agent': ' ',
|
||||||
|
Cookie: 'gd=1'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const responseText = request.data as string
|
||||||
|
const responseSplit = responseText.split('#')[0].split('|')
|
||||||
|
|
||||||
|
return jsonResponse(
|
||||||
|
responseSplit.map(item => {
|
||||||
|
const split = splitGd(item)
|
||||||
|
return {
|
||||||
|
id: split['1'],
|
||||||
|
name: split['2'],
|
||||||
|
levels: split['3'].split(','),
|
||||||
|
stars: split['4'],
|
||||||
|
coins: split['5'],
|
||||||
|
difficulty: split['6'],
|
||||||
|
barColor: JSON.parse('[' + split['7'] + ']'),
|
||||||
|
textColor: JSON.parse('[' + split['8'] + ']')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import axios from 'axios'
|
||||||
|
import { jsonResponse, splitGd } from '../../../lib/util'
|
||||||
|
|
||||||
|
export const handler = async () => {
|
||||||
|
const request = await axios.post(
|
||||||
|
'https://www.boomlings.com/database/getGJMapPacks21.php',
|
||||||
|
new URLSearchParams({
|
||||||
|
gameVersion: '22',
|
||||||
|
binaryVersion: '45',
|
||||||
|
count: '250',
|
||||||
|
page: '0',
|
||||||
|
secret: 'Wmfd2893gb7'
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'User-Agent': ' ',
|
||||||
|
Cookie: 'gd=1'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const responseText = request.data as string
|
||||||
|
const responseSplit = responseText.split('#')[0].split('|')
|
||||||
|
|
||||||
|
return jsonResponse(
|
||||||
|
responseSplit.map(item => {
|
||||||
|
const split = splitGd(item)
|
||||||
|
return {
|
||||||
|
id: split['1'],
|
||||||
|
name: split['2'],
|
||||||
|
levels: split['3'].split(','),
|
||||||
|
stars: split['4'],
|
||||||
|
coins: split['5'],
|
||||||
|
difficulty: split['6'],
|
||||||
|
barColor: JSON.parse('[' + split['7'] + ']'),
|
||||||
|
textColor: JSON.parse('[' + split['8'] + ']')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -12,6 +12,10 @@ import { handler as leaderboardsLevelGetHandler } from './routes/leaderboards/le
|
|||||||
|
|
||||||
import { handler as mapPacksGetHandler } from './routes/map-packs/get'
|
import { handler as mapPacksGetHandler } from './routes/map-packs/get'
|
||||||
|
|
||||||
|
import { handler as commentsAccountGetHandler } from './routes/comments/account/get'
|
||||||
|
import { handler as commentsAccountHistoryGetHandler } from './routes/comments/account/history/get'
|
||||||
|
import { handler as commentsLevelGetHandler } from './routes/comments/level/get'
|
||||||
|
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
||||||
const app = new Elysia().use(
|
const app = new Elysia().use(
|
||||||
@@ -120,6 +124,58 @@ app.get('/weekly-level', () => eventLevelGetHandler('1'), {
|
|||||||
tags: ['Levels']
|
tags: ['Levels']
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
app.get('/comments/account', handler => commentsAccountGetHandler(handler), {
|
||||||
|
detail: {
|
||||||
|
description: 'The endpoint for getting account comments',
|
||||||
|
tags: ['Accounts', 'Comments']
|
||||||
|
},
|
||||||
|
query: t.Object({
|
||||||
|
id: t.String({ description: 'This is the account ID.' }),
|
||||||
|
page: t.Optional(
|
||||||
|
t.String({
|
||||||
|
description:
|
||||||
|
'The page you want to get, starts from `0`. Default is `0`.'
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
app.get(
|
||||||
|
'/comments/account/history',
|
||||||
|
handler => commentsAccountHistoryGetHandler(handler),
|
||||||
|
{
|
||||||
|
detail: {
|
||||||
|
description: 'The endpoint for getting account comment history',
|
||||||
|
tags: ['Accounts', 'Comments']
|
||||||
|
},
|
||||||
|
query: t.Object({
|
||||||
|
id: t.String({ description: 'This is the user ID.' }),
|
||||||
|
page: t.Optional(
|
||||||
|
t.String({
|
||||||
|
description:
|
||||||
|
'The page you want to get, starts from `0`. Default is `0`.'
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
app.get('/comments/level', handler => commentsLevelGetHandler(handler), {
|
||||||
|
detail: {
|
||||||
|
description: 'The endpoint for getting level comments',
|
||||||
|
tags: ['Levels', 'Comments']
|
||||||
|
},
|
||||||
|
query: t.Object({
|
||||||
|
id: t.String({ description: 'This is the level ID.' }),
|
||||||
|
page: t.Optional(
|
||||||
|
t.String({
|
||||||
|
description:
|
||||||
|
'The page you want to get, starts from `0`. Default is `0`.'
|
||||||
|
})
|
||||||
|
),
|
||||||
|
mode: t.Union([t.Literal('0'), t.Literal('1')], {
|
||||||
|
description: '0 for top, 1 for recent'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
app.get(
|
app.get(
|
||||||
'/',
|
'/',
|
||||||
() =>
|
() =>
|
||||||
|
|||||||
+20
-2
@@ -5,8 +5,11 @@ export const jsonResponse = (data: any, status = 200) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const splitGd = (input: string): Record<string, string> => {
|
export const splitGd = (
|
||||||
const parts = input.split(':')
|
input: string,
|
||||||
|
splitKey: string = ':'
|
||||||
|
): Record<string, string> => {
|
||||||
|
const parts = input.split(splitKey)
|
||||||
const result: Record<string, string> = {}
|
const result: Record<string, string> = {}
|
||||||
for (let i = 0; i < parts.length - 1; i += 2) {
|
for (let i = 0; i < parts.length - 1; i += 2) {
|
||||||
result[parts[i]] = parts[i + 1]
|
result[parts[i]] = parts[i + 1]
|
||||||
@@ -54,3 +57,18 @@ export const formatTime = (seconds: number): string => {
|
|||||||
|
|
||||||
return parts.join(' ') || '0s'
|
return parts.join(' ') || '0s'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Taken from https://github.com/GDColon/GDBrowser/blob/master/index.js#L164-L173
|
||||||
|
export const parseResponse = (responseBody: string, splitter = ':') => {
|
||||||
|
if (!responseBody || responseBody == '-1') return {}
|
||||||
|
if (responseBody.startsWith('\nWarning:'))
|
||||||
|
responseBody = responseBody.split('\n').slice(2).join('\n').trim() // GDPS'es are wild
|
||||||
|
if (responseBody.startsWith('<br />'))
|
||||||
|
responseBody = responseBody.split('<br />').slice(2).join('<br />').trim() // Seriously screw this
|
||||||
|
let response = responseBody.split('#')[0].split(splitter)
|
||||||
|
let res: any = {}
|
||||||
|
for (let i = 0; i < response.length; i += 2) {
|
||||||
|
res[response[i]] = response[i + 1]
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import axios from 'axios'
|
||||||
|
import { jsonResponse, parseResponse, splitGd } from '../../../lib/util'
|
||||||
|
import { Context } from 'elysia'
|
||||||
|
|
||||||
|
export const handler = async (handler: Context) => {
|
||||||
|
const id = handler.query.id
|
||||||
|
const page = handler.query.page
|
||||||
|
|
||||||
|
const request = await axios.post(
|
||||||
|
'https://www.boomlings.com/database/getGJAccountComments20.php',
|
||||||
|
new URLSearchParams({
|
||||||
|
gameVersion: '22',
|
||||||
|
binaryVersion: '45',
|
||||||
|
accountID: id,
|
||||||
|
page: page ?? '0',
|
||||||
|
secret: 'Wmfd2893gb7'
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'User-Agent': ' ',
|
||||||
|
Cookie: 'gd=1'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const responseText = request.data as string
|
||||||
|
const responseSplit = responseText
|
||||||
|
.split('|')
|
||||||
|
.map(x => x.split(':'))
|
||||||
|
.map(x => x.map(x => parseResponse(x, '~')))
|
||||||
|
|
||||||
|
return jsonResponse(
|
||||||
|
responseSplit.map(item => {
|
||||||
|
const commentInfo = item[0]
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: +commentInfo['6'],
|
||||||
|
content: atob(commentInfo['2']),
|
||||||
|
likes: +commentInfo['4'],
|
||||||
|
date: commentInfo['9'] + ' ago'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import axios from 'axios'
|
||||||
|
import { jsonResponse, parseResponse } from '../../../../lib/util'
|
||||||
|
import { Context } from 'elysia'
|
||||||
|
|
||||||
|
export const handler = async (handler: Context) => {
|
||||||
|
const id = handler.query.id
|
||||||
|
const page = handler.query.page
|
||||||
|
|
||||||
|
const request = await axios.post(
|
||||||
|
'https://www.boomlings.com/database/getGJCommentHistory.php',
|
||||||
|
new URLSearchParams({
|
||||||
|
gameVersion: '22',
|
||||||
|
binaryVersion: '45',
|
||||||
|
page: page ?? '0',
|
||||||
|
secret: 'Wmfd2893gb7',
|
||||||
|
mode: '1',
|
||||||
|
userID: id
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'User-Agent': ' ',
|
||||||
|
Cookie: 'gd=1'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const responseText = request.data as string
|
||||||
|
const responseSplit = responseText
|
||||||
|
.split('|')
|
||||||
|
.map(x => x.split(':'))
|
||||||
|
.map(x => x.map(x => parseResponse(x, '~')))
|
||||||
|
|
||||||
|
return jsonResponse(
|
||||||
|
responseSplit.map(item => {
|
||||||
|
const commentInfo = item[0]
|
||||||
|
const accountInfo = item[1]
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: +commentInfo['6'],
|
||||||
|
levelId: +commentInfo['1'],
|
||||||
|
content: atob(commentInfo['2']),
|
||||||
|
likes: +commentInfo['4'],
|
||||||
|
date: commentInfo['9'] + ' ago',
|
||||||
|
commentColor: commentInfo['12']
|
||||||
|
? JSON.parse('[' + commentInfo['12'] + ']')
|
||||||
|
: [255, 255, 255],
|
||||||
|
account: {
|
||||||
|
username: accountInfo['1'],
|
||||||
|
moderator: +accountInfo['15'],
|
||||||
|
playerId: +accountInfo['11'],
|
||||||
|
accountId: +accountInfo['16'],
|
||||||
|
icon: {
|
||||||
|
form: ['icon', 'ship', 'ball', 'ufo', 'wave', 'robot', 'spider'][
|
||||||
|
+accountInfo['14']
|
||||||
|
],
|
||||||
|
icon: +accountInfo['9'],
|
||||||
|
col1: +accountInfo['10'],
|
||||||
|
col2: +accountInfo['11'],
|
||||||
|
colG: +accountInfo['51'],
|
||||||
|
glow: +accountInfo['15'] > 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import axios from 'axios'
|
||||||
|
import { jsonResponse, parseResponse, splitGd } from '../../../lib/util'
|
||||||
|
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 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,
|
||||||
|
levelID: id
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'User-Agent': ' ',
|
||||||
|
Cookie: 'gd=1'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const responseText = request.data as string
|
||||||
|
const responseSplit = responseText
|
||||||
|
.split('|')
|
||||||
|
.map(x => x.split(':'))
|
||||||
|
.map(x => x.map(x => parseResponse(x, '~')))
|
||||||
|
|
||||||
|
return jsonResponse(
|
||||||
|
responseSplit.map(item => {
|
||||||
|
const commentInfo = item[0]
|
||||||
|
const accountInfo = item[1]
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: +commentInfo['6'],
|
||||||
|
content: atob(commentInfo['2']),
|
||||||
|
likes: +commentInfo['4'],
|
||||||
|
date: commentInfo['9'] + ' ago',
|
||||||
|
commentColor: commentInfo['12']
|
||||||
|
? JSON.parse('[' + commentInfo['12'] + ']')
|
||||||
|
: [255, 255, 255],
|
||||||
|
account: {
|
||||||
|
username: accountInfo['1'],
|
||||||
|
moderator: +accountInfo['15'],
|
||||||
|
playerId: +accountInfo['11'],
|
||||||
|
accountId: +accountInfo['16'],
|
||||||
|
icon: {
|
||||||
|
form: ['icon', 'ship', 'ball', 'ufo', 'wave', 'robot', 'spider'][
|
||||||
|
+accountInfo['14']
|
||||||
|
],
|
||||||
|
icon: +accountInfo['9'],
|
||||||
|
col1: +accountInfo['10'],
|
||||||
|
col2: +accountInfo['11'],
|
||||||
|
colG: +accountInfo['51'],
|
||||||
|
glow: +accountInfo['15'] > 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in new issue
Block a user