Added ability to parse players.msgpack

This commit is contained in:
BurnyLlama 2021-10-09 19:26:30 +02:00
parent 0058b6eed2
commit 9972572b3a
3 changed files with 24 additions and 0 deletions

1
.gitignore vendored
View File

@ -120,4 +120,5 @@ dist
package-lock.json
pnpm-lock.yaml
ddnet.sqlite
players.msgpack
.env

View File

@ -0,0 +1,22 @@
import fs from 'fs'
import msgpack from '@msgpack/msgpack'
/**
* This module parses the msgpack provided by DDNet...
* @module libs/database/sqlite2mongo/decodeMsgpack
*/
export default function decodeMsgpack() {
const data = fs.readFileSync('players.msgpack')
const decoded = msgpack.decodeMulti(data, {wrap: true})
const order = ['categories', 'maps', 'totalPoints', 'pointsRanks', 'pointsThisWeek', 'pointsThisMonth', 'teamRankPoints', 'rankPoints', 'serverRanks']
let final = {}
let i = 0
for (const part of decoded) {
final[order[i]] = part
++i
}
return final
}

View File

@ -17,6 +17,7 @@
"author": "BurnyLlama, furo",
"license": "WTFPL",
"dependencies": {
"@msgpack/msgpack": "^2.7.1",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"mongoose": "^6.0.7",