Added ability to parse players.msgpack
This commit is contained in:
parent
0058b6eed2
commit
9972572b3a
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -120,4 +120,5 @@ dist
|
||||||
package-lock.json
|
package-lock.json
|
||||||
pnpm-lock.yaml
|
pnpm-lock.yaml
|
||||||
ddnet.sqlite
|
ddnet.sqlite
|
||||||
|
players.msgpack
|
||||||
.env
|
.env
|
22
libs/database/sqlite2mongo/decodeMsgpack.js
Normal file
22
libs/database/sqlite2mongo/decodeMsgpack.js
Normal 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
|
||||||
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
"author": "BurnyLlama, furo",
|
"author": "BurnyLlama, furo",
|
||||||
"license": "WTFPL",
|
"license": "WTFPL",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@msgpack/msgpack": "^2.7.1",
|
||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"mongoose": "^6.0.7",
|
"mongoose": "^6.0.7",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user