|
|
@ -13,7 +13,7 @@ let e9 = 'https://e926.net/post/show/'; |
|
|
|
|
|
|
|
const version = '0.1.0'; |
|
|
|
|
|
|
|
module.exports = async function SourceFynnder(enabled, msg) { |
|
|
|
async function SourceFynnderBot(enabled, msg) { |
|
|
|
if (!enabled || enabled === null || enabled === undefined) return; |
|
|
|
res = msg.content.match(md5); |
|
|
|
if (!res) return; |
|
|
@ -23,8 +23,12 @@ module.exports = async function SourceFynnder(enabled, msg) { |
|
|
|
let URL = res[m]; |
|
|
|
let hash = URL.split(md5)[2]; |
|
|
|
|
|
|
|
let { data } = await axios.get(search_md5 + hash, { |
|
|
|
headers: { 'user-agent': `SourceFynnder/${version} (ry / codepupper)` } |
|
|
|
let { |
|
|
|
data |
|
|
|
} = await axios.get(search_md5 + hash, { |
|
|
|
headers: { |
|
|
|
'user-agent': `SourceFynnder/${version} (ry / codepupper)` |
|
|
|
} |
|
|
|
}); |
|
|
|
if (data.rating === 's') { |
|
|
|
Source = e9 + data.id; |
|
|
@ -35,24 +39,40 @@ module.exports = async function SourceFynnder(enabled, msg) { |
|
|
|
} |
|
|
|
msg.channel.send(Sources); |
|
|
|
await backend.add('SourceFynnder.found', Sources.length); |
|
|
|
await backend.add('SourceFynnder.foundBot', Sources.length); |
|
|
|
await Servers.add(`${msg.guild.id}.foundSources`, Sources.length); |
|
|
|
}; |
|
|
|
/* url = msg.content.split(md5); |
|
|
|
hash = url[2]; |
|
|
|
|
|
|
|
if (hash === undefined) return; |
|
|
|
|
|
|
|
let res = await axios.get(search_md5 + hash); |
|
|
|
|
|
|
|
let data = res.data; |
|
|
|
let Source; |
|
|
|
if (data.rating === "s") { |
|
|
|
Source = e9 + data.id; |
|
|
|
} else { |
|
|
|
Source = e6 + data.id; |
|
|
|
} |
|
|
|
async function SourceFynnderAPI(url) { |
|
|
|
url = url.toString().replace(/\,/g, ' ') |
|
|
|
res = url.match(md5); |
|
|
|
if (!res) throw new Error('Not a Valid e621/e926 URL'); |
|
|
|
|
|
|
|
let Sources = []; |
|
|
|
for (const m in res) { |
|
|
|
let URL = res[m]; |
|
|
|
let hash = URL.split(md5)[2]; |
|
|
|
|
|
|
|
let { |
|
|
|
data |
|
|
|
} = await axios.get(search_md5 + hash, { |
|
|
|
headers: { |
|
|
|
'user-agent': `SourceFynnder/${version} (ry / codepupper)` |
|
|
|
} |
|
|
|
}); |
|
|
|
if (data.rating === 's') { |
|
|
|
Source = e9 + data.id; |
|
|
|
} else { |
|
|
|
Source = e6 + data.id; |
|
|
|
} |
|
|
|
Sources.push(`${Source}`); |
|
|
|
} |
|
|
|
await backend.add('SourceFynnder.found', Sources.length); |
|
|
|
await backend.add('SourceFynnder.foundAPI', Sources.length); |
|
|
|
return Sources |
|
|
|
}; |
|
|
|
|
|
|
|
console.log(Source); |
|
|
|
return msg.channel.send(Source); */ |
|
|
|
module.exports = { |
|
|
|
SourceFynnder: SourceFynnderBot, |
|
|
|
APIFind: SourceFynnderAPI |
|
|
|
} |