You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.0 KiB

const { program } = require('commander')
const fetch = require('node-fetch');
const javalon = require('javalon')
program
.option('-d, --debug', 'Output extra debugging')
.option('-U, --url <url>', 'Talk to an alternate blacklist service', "https://avalonblacklist.nannal.com/")
.option('-l,--list <black>', 'Which list to add the target to', "black")
.option('-a,--approve <nannal>', 'Expand the list of approved list editors')
.option('-r,--reason <piracy>', 'Justify why a user should be added to the provided list')
.option('-t,--target <coviddoubter2020>', 'Which user will be added to the list')
.requiredOption('-k,--key <key>', 'Any valid private key for your DTube user')
.requiredOption('-u,--user <myUser>', 'Your DTube username')
program.parse(process.argv)
if (!program.list=="black" && program.approve){
console.log("Please choose either -a or -l, you can't approve and add someone to a list at the same time")
} else if (program.target && !program.reason) {
console.log("Please inform other users why you put the user on the chosen list")
} else {
if (program.approve){
approve()
} else if (program.list) {
addToList()
} else {
console.log("Please choose either -a or -l, you can't approve and add someone to a list at the same time")
}
}
async function approve() {
body = javalon.sign(program.key, program.user, {user:program.approve})
console.log(body)
const response = await fetch(program.url+'approve', {
method: 'post',
body: JSON.stringify(body),
headers: {'Content-Type': 'application/json'}
});
const json = await response.json();
console.log(json);
}
async function addToList() {
body = javalon.sign(program.key, program.user, {user: program.target, status: program.list, reason: program.reason})
const response = await fetch(program.url+'submit', {
method: 'post',
body: JSON.stringify(body),
headers: {'Content-Type': 'application/json'}
});
const json = await response.json();
console.log(json);
}