add vote ratio to pr0gag trigger
remove debug console.log
This commit is contained in:
parent
8a1fa9dddf
commit
22d79eed18
|
@ -12,7 +12,7 @@ const color = new Proxy({}, {
|
|||
|
||||
const flags = {
|
||||
1: color.green("sfw"),
|
||||
2: color.brown("nsfw"),
|
||||
2: color.magenta("nsfw"),
|
||||
4: color.red("nsfl"),
|
||||
8: color.blue("nsfp")
|
||||
};
|
||||
|
@ -46,7 +46,6 @@ export default bot => {
|
|||
? matches[2].slice(0, -3) + "jpg"
|
||||
: matches[2];
|
||||
const response = await (await fetch(apis.reverse + path)).json();
|
||||
console.log(response);
|
||||
if(response.error || !response.items.length)
|
||||
throw "reverse lookup error";
|
||||
id = response.items[0].id;
|
||||
|
@ -71,9 +70,22 @@ export default bot => {
|
|||
.map(tag => tag.tag)
|
||||
.join(", ");
|
||||
|
||||
const voteRatio = list.up / (list.up + list.down);
|
||||
|
||||
const voteRatioColors = [
|
||||
"red",
|
||||
"brown",
|
||||
"orange",
|
||||
"yellow",
|
||||
"green",
|
||||
"lightgreen",
|
||||
];
|
||||
|
||||
const voteRatioColor = voteRatioColors[~~Math.min(voteRatio * voteRatioColors.length, voteRatioColors.length - 1)];
|
||||
|
||||
reply = [
|
||||
"https://pr0gramm.com/" + (list.promoted ? "top" : "new") + "/" + id,
|
||||
`${list.up - list.down} (${color.green(list.up)} / ${color.red(list.down)})`,
|
||||
`${list.up - list.down} (${color.green(list.up)} / ${color.red(list.down)} = ${color[voteRatioColor]((voteRatio * 100).toFixed(1))}${color.magenta("%")})`,
|
||||
"user: " + list.user,
|
||||
"comments: " + info.comments.length,
|
||||
`toptags: ${toptags} (${flags[list.flags]})`
|
||||
|
|
Loading…
Reference in New Issue
Block a user