Finish hashing system
This commit is contained in:
parent
85ef6b3d40
commit
520e2a8abd
3 changed files with 47 additions and 2 deletions
|
@ -18,10 +18,28 @@ module.exports={
|
||||||
}
|
}
|
||||||
const cmd=text.split(" ");
|
const cmd=text.split(" ");
|
||||||
let verify=hashcheck(cmd);
|
let verify=hashcheck(cmd);
|
||||||
|
if(verify>0){
|
||||||
|
text=cmd.slice(0,cmd.length-1).join(" ");
|
||||||
|
}
|
||||||
if(cmds[cmd[0].toLowerCase()]){
|
if(cmds[cmd[0].toLowerCase()]){
|
||||||
|
const command = cmds[cmd[0].toLowerCase()];
|
||||||
|
if(command.level!==undefined && command.level>verify){
|
||||||
|
b.tellraw(uuid,{
|
||||||
|
text:"You do not have permission to run this command. If you have permission, please make sure you put the command hash at the end, or ran the command through your client's hashing system."
|
||||||
|
});
|
||||||
|
b.tellraw(uuid,{
|
||||||
|
text:"Your permission level: "+verify
|
||||||
|
});
|
||||||
|
b.tellraw(uuid,{
|
||||||
|
text:"Command requires: "+command.level
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
try{
|
try{
|
||||||
cmds[cmd[0].toLowerCase()].execute(new Command(uuid,name,"nick N/A",text,prefix,b,verify))
|
cmds[cmd[0].toLowerCase()].execute(new Command(uuid,name,"nick N/A",text,prefix,b,verify))
|
||||||
} catch(e) { console.log(e); b.chat("An error occured (check console for more info)") }
|
} catch(e) {
|
||||||
|
console.log(e); b.chat("An error occured (check console for more info)")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b.printHelp=(uuid,prefix)=>{
|
b.printHelp=(uuid,prefix)=>{
|
||||||
|
|
14
plugins/commands/verify.js
Normal file
14
plugins/commands/verify.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
module.exports={
|
||||||
|
execute: (c)=>{
|
||||||
|
c.reply({
|
||||||
|
text: c.verify+""
|
||||||
|
})
|
||||||
|
c.reply({
|
||||||
|
text: c.command
|
||||||
|
})
|
||||||
|
},
|
||||||
|
desc: "Does nothing", // Command description
|
||||||
|
usage: ' <required> [optional]', // Command usage
|
||||||
|
hidden: false, // To show the command on the help command list, remove this line
|
||||||
|
level: 1
|
||||||
|
}
|
|
@ -1,6 +1,19 @@
|
||||||
|
const crypto=require("crypto");
|
||||||
|
const settings = require("../settings.json");
|
||||||
|
const secret = require(settings.secret);
|
||||||
module.exports = function (cmd) {
|
module.exports = function (cmd) {
|
||||||
if(true){
|
const cmdWithoutHash=cmd.slice(0,cmd.length-1).join(" ");
|
||||||
|
const _dateString=Date.now().toString();
|
||||||
|
const dateString=_dateString.slice(0,_dateString.length-4);
|
||||||
|
const hashTrusted="babyboom:"+secret.keyTrusted+":"+cmdWithoutHash+":"+dateString
|
||||||
|
const hashOwner="babyboom:"+secret.keyOwner+":"+cmdWithoutHash+":"+dateString
|
||||||
|
const validhashT=crypto.createHash("sha256").update(hashTrusted).digest("hex");
|
||||||
|
const validhashO=crypto.createHash("sha256").update(hashOwner).digest("hex");
|
||||||
|
if(cmd[cmd.length-1]==validhashT){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if(cmd[cmd.length-1]==validhashO){
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue