pr0gag parser test
This commit is contained in:
parent
7d2bbcde4c
commit
302cb8ffe4
@ -11,6 +11,7 @@ import kernel from "./kernel";
|
|||||||
import lastfm from "./lastfm";
|
import lastfm from "./lastfm";
|
||||||
import mcmaniac from "./mcmaniac";
|
import mcmaniac from "./mcmaniac";
|
||||||
import parser from "./parser";
|
import parser from "./parser";
|
||||||
|
import pr0gag from "./pr0gag";
|
||||||
import quotes from "./quotes";
|
import quotes from "./quotes";
|
||||||
import rape from "./rape";
|
import rape from "./rape";
|
||||||
import sandbox from "./sandbox";
|
import sandbox from "./sandbox";
|
||||||
@ -24,6 +25,6 @@ import wttr from "./wttr";
|
|||||||
export default [
|
export default [
|
||||||
cfg, chatbot, coins, cookie, core, debug,
|
cfg, chatbot, coins, cookie, core, debug,
|
||||||
drugs, help, irpg, kernel, lastfm, mcmaniac,
|
drugs, help, irpg, kernel, lastfm, mcmaniac,
|
||||||
parser, quotes, rape, sandbox, soundcloud,
|
parser, pr0gag, quotes, rape, sandbox, soundcloud,
|
||||||
timer, urban, nxy, uwe, wttr
|
timer, urban, nxy, uwe, wttr
|
||||||
];
|
];
|
||||||
|
67
src/inc/trigger/pr0gag.mjs
Normal file
67
src/inc/trigger/pr0gag.mjs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
import rp from "request-promise";
|
||||||
|
import url from "url";
|
||||||
|
|
||||||
|
const apis = {
|
||||||
|
reverse: "https://totally.rip/pr0/img_reverse_lookup.php?image=",
|
||||||
|
pr0gag: {
|
||||||
|
list: "https://pr0gramm.com/api/items/get/?flags=15&id=",
|
||||||
|
item: "https://pr0gramm.com/api/items/info?flags=15&itemId="
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const flags = {
|
||||||
|
1: "sfw",
|
||||||
|
2: "nsfw",
|
||||||
|
4: "nsfl",
|
||||||
|
8: "nsfp"
|
||||||
|
};
|
||||||
|
const regex = /img\.pr0gramm\.com\/((?:\d+){4}\/(?:\d+){2}\/(?:\d+){2}\/(?:\w{16})\.(?:webm|png|jpg|mp4|webm)?)/gi;
|
||||||
|
const site = "https://pr0gramm.com/new/";
|
||||||
|
|
||||||
|
export default bot => {
|
||||||
|
bot._trigger.set("pr0gag", new bot.trigger({
|
||||||
|
call: /img\.programm\.com.*/i,
|
||||||
|
set: "uwe",
|
||||||
|
f: e => {
|
||||||
|
const link = e.message.match(regex)[0];
|
||||||
|
const tmp = url.parse(link).path.substr(1);
|
||||||
|
rp(apis.reverse + tmp)
|
||||||
|
.then(res => JSON.parse(res).id)
|
||||||
|
.then(id => Promise.all([
|
||||||
|
rp(apis.pr0gag.list + id.toString()),
|
||||||
|
rp(apis.pr0gag.item + id.toString()),
|
||||||
|
id
|
||||||
|
])
|
||||||
|
.then(([list, item, id]) => [
|
||||||
|
JSON.parse(list).items.filter(item => item.id === id)[0],
|
||||||
|
JSON.parse(item),
|
||||||
|
id
|
||||||
|
])
|
||||||
|
.then(([list, item, id]) => ({
|
||||||
|
created: list.created,
|
||||||
|
up: list.up,
|
||||||
|
down: list.down,
|
||||||
|
score: list.up - list.down,
|
||||||
|
ratio: (list.up / (list.up + list.down)).toFixed(2),
|
||||||
|
flags: flags[list.flags],
|
||||||
|
user: list.user,
|
||||||
|
comments: item.comments.length,
|
||||||
|
toptags: item.tags.splice(0, 3).map(tag => tag.tag),
|
||||||
|
link: site + id.toString()
|
||||||
|
}))
|
||||||
|
.then(meta => [
|
||||||
|
`c: ${meta.created}`,
|
||||||
|
`u: ${meta.up}`,
|
||||||
|
`d: ${meta.down}`,
|
||||||
|
`s: ${meta.score}`,
|
||||||
|
`r: ${meta.ratio}`,
|
||||||
|
`f: ${meta.flags}`,
|
||||||
|
`u: ${meta.user}`,
|
||||||
|
`co: ${meta.comments}`,
|
||||||
|
`t: ${meta.toptags}`,
|
||||||
|
`l: ${meta.link}`
|
||||||
|
].join("; "))
|
||||||
|
.then(out => e.reply(out))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user