Last active
June 23, 2022 19:35
-
-
Save foglio1024/08f871d98323cae07e51f4aaddfe013b to your computer and use it in GitHub Desktop.
TeraBackup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const fs = require('fs'); | |
module.exports = function TeraBackup(mod) { | |
let enabled = true; | |
let file = path.join(__dirname, 'tera-log-' + Date.now() + '.log'); | |
mod.hook('*', 'raw', { order: -Infinity, filters: { fake: null } }, (code, data, fromServer) => { | |
if (!enabled) return | |
const now = new Date(); | |
const timeStr = `[${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}:${now.getSeconds().toString().padStart(2, '0')}.${now.getMilliseconds().toString().padStart(3, '0')}] `; | |
fs.appendFileSync(file, timeStr + (fromServer ? '<-' : '->') + ' ' + ((mod.dispatch.protocolMap ? mod.dispatch.protocolMap.code.get(code) : null) || code) + ' ' + ((data.length > 4) ? data.slice(4).toString('hex').match(/.{2}/g).join(' ') : '') + '\n') | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "terabackup", | |
"author": "Foglio", | |
"disableAutoUpdate": true, | |
"keywords": ["network"], | |
"options": { | |
"cliName": "terabackup", | |
"guiName": "TERA Backup" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment