Rewrite username generator

This commit is contained in:
7cc5c4f330d47060 2024-07-19 15:52:38 -04:00
parent 36ea00e07a
commit add4e26f13
2 changed files with 15 additions and 4 deletions

View file

@ -1,5 +1,6 @@
const m = require("minecraft-protocol")
const settings = require("./settings.json")
const generateUser = require("./util/usergen.js")
const secret = require(settings.secret)
const EventEmitter = require("node:events")
const crypto = require("crypto")
@ -7,10 +8,6 @@ const fs=require("fs")
module.exports.bot=[];
const generateUser = function generateUser(){
return "@s["+crypto.randomBytes(2).toString("hex")+"_= \xa7"+crypto.randomBytes(2).toString("hex")
}
const loadplug = (botno) => {
const botplug = []
const bpl = fs.readdirSync('plugins')

14
util/usergen.js Normal file
View file

@ -0,0 +1,14 @@
const rsg=function(count){
let output="";
for(let i=0; i<count; i++){
let rng=Math.floor(Math.random()*16)+1;
if(rng==7) rng=17; //No bells
if(rng==10) rng=18; //No line feeds
if(rng==13) rng=19; //No carriage returns
output+=String.fromCharCode(rng)
}
return output;
}
module.exports = function () {
return " \xa7"+rsg(6)+" "+rsg(4)
}