mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 14:21:41 +02:00
Use sagiri npm module instead
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
const Command = require('../../framework/Command');
|
const Command = require('../../framework/Command');
|
||||||
const request = require('node-superfetch');
|
const sagiri = require('sagiri');
|
||||||
|
const { SAUCENAO_KEY } = process.env;
|
||||||
|
const sagiriClient = sagiri(SAUCENAO_KEY);
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { readFile } = require('fs/promises');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const images = fs.readdirSync(path.join(__dirname, '..', '..', 'assets', 'images', 'xiao'));
|
const images = fs.readdirSync(path.join(__dirname, '..', '..', 'assets', 'images', 'xiao'));
|
||||||
const { SAUCENAO_KEY } = process.env;
|
|
||||||
const sourceRegex = /([A-Z ]+)-?([0-9A-Z]+)?(-[0-9]+)?(\.[A-Z])?/i;
|
const sourceRegex = /([A-Z ]+)-?([0-9A-Z]+)?(-[0-9]+)?(\.[A-Z])?/i;
|
||||||
|
|
||||||
module.exports = class XiaoCommand extends Command {
|
module.exports = class XiaoCommand extends Command {
|
||||||
@@ -56,19 +56,7 @@ module.exports = class XiaoCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async sauceNao(img) {
|
sauceNao(img) {
|
||||||
const { body } = await request.post('https://saucenao.com/search.php')
|
return sagiriClient(path.join(__dirname, '..', '..', 'assets', 'images', 'xiao', img));
|
||||||
.query({
|
|
||||||
api_key: SAUCENAO_KEY,
|
|
||||||
db: 999,
|
|
||||||
output_type: 2,
|
|
||||||
numres: 16
|
|
||||||
})
|
|
||||||
.attach('file', await readFile(path.join(__dirname, '..', '..', 'assets', 'images', 'xiao', img)));
|
|
||||||
console.log(body.header.message);
|
|
||||||
if (!body.results || !body.results.length) return null;
|
|
||||||
const result = body.results[0];
|
|
||||||
if (Number.parseFloat(result.header.similarity) < 90) return null;
|
|
||||||
return body.results[0].data;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
"parse-domain": "^8.0.2",
|
"parse-domain": "^8.0.2",
|
||||||
"pokersolver": "^2.1.4",
|
"pokersolver": "^2.1.4",
|
||||||
"random-js": "^2.1.0",
|
"random-js": "^2.1.0",
|
||||||
|
"sagiri": "^3.4.0",
|
||||||
"semver": "^7.6.0",
|
"semver": "^7.6.0",
|
||||||
"sherlockjs": "^1.4.2",
|
"sherlockjs": "^1.4.2",
|
||||||
"stackblur-canvas": "^2.7.0",
|
"stackblur-canvas": "^2.7.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user