diff --git a/.gitignore b/.gitignore index 44683e3..e10ac50 100644 --- a/.gitignore +++ b/.gitignore @@ -120,4 +120,5 @@ dist package-lock.json pnpm-lock.yaml ddnet.sqlite +players.msgpack .env \ No newline at end of file diff --git a/libs/database/sqlite2mongo/decodeMsgpack.js b/libs/database/sqlite2mongo/decodeMsgpack.js new file mode 100644 index 0000000..7a3f511 --- /dev/null +++ b/libs/database/sqlite2mongo/decodeMsgpack.js @@ -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 +} + diff --git a/package.json b/package.json index 5af0f44..dc91659 100644 --- a/package.json +++ b/package.json @@ -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",