Compare commits
No commits in common. "348ee8ea2a5e1798dd42f118e072fdc903e7c438" and "ce435d01a16bc5dfcd15c63182a7728b3edb47cc" have entirely different histories.
348ee8ea2a
...
ce435d01a1
@ -4,9 +4,8 @@ var fs = require("fs");
|
||||
|
||||
client.on("messageCreate", async message => {
|
||||
if (message.guild.id != config.guild) return;
|
||||
if (message.author.id == client.user.id) return;
|
||||
let pixiv_urls = new Set(message.content.match(/https?:\/\/www\.pixiv\.net\/en\/artworks\/\d+\b/g));
|
||||
if (!pixiv_urls.size) return;
|
||||
let pixiv_ids = new Set(Array.from(message.content.matchAll(/https?:\/\/www\.pixiv\.net\/en\/artworks\/(\d+)\b/g)).map(x=>x[1]));
|
||||
if (!pixiv_ids.size) return;
|
||||
message.suppressEmbeds();
|
||||
// suppressing embeds doesn't work on embeds that load after
|
||||
client.on("messageUpdate", function arf(g,updatedMessage) {
|
||||
@ -19,17 +18,14 @@ client.on("messageCreate", async message => {
|
||||
client.removeListener("messageUpdate", arf);
|
||||
}
|
||||
});
|
||||
for (let pixiv_url of pixiv_urls) {
|
||||
for (let pixiv_id of pixiv_ids) {
|
||||
try {
|
||||
let illust = Object.values(JSON.parse((await (await fetch(pixiv_url)).text()).match(/<meta name="preload-data" id="meta-preload-data" content='(.*)'>/)[1]).illust)[0];
|
||||
let msg = "";
|
||||
for (let i = 0; i < illust.pageCount; i++) {
|
||||
msg += illust.urls.original.replace('p0', 'p'+i).replace("https://i.pximg.net/", `https://${config.web_hostname}/pixiv-proxy/`) + '\n';
|
||||
}
|
||||
await message.channel.send(msg);
|
||||
let json = await (await fetch(`https://www.pixiv.net/ajax/illust/${pixiv_id}/pages`)).text();
|
||||
let data = JSON.parse(json);
|
||||
if (data.error) { console.error(`pixiv ajax said error for ${pixiv_id}: ${data.error}`); continue}
|
||||
await message.channel.send(data.body.map(o => o.urls.original.replace("https://i.pximg.net/", `https://${config.web_hostname}/pixiv-proxy/`)).join('\n'));
|
||||
} catch (error) {
|
||||
console.error("pixiv embed error,", error.message);
|
||||
message.react('⚠');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user