mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 06:45:31 +02:00
Detect face image size
This commit is contained in:
@@ -38,6 +38,7 @@ module.exports = class FaceCommand extends Command {
|
||||
try {
|
||||
const face = await this.detect(image);
|
||||
if (!face) return msg.reply('There are no faces in this image.');
|
||||
if (face === 'size') return msg.reply('This image is too large.');
|
||||
const pronoun = face.gender.value === 'Male' ? 'He' : 'She';
|
||||
const emotion = emotionResponse[emotions.indexOf(
|
||||
emotions.slice(0).sort((a, b) => face.emotion[b] - face.emotion[a])[0]
|
||||
@@ -57,12 +58,14 @@ module.exports = class FaceCommand extends Command {
|
||||
}
|
||||
|
||||
async detect(image) {
|
||||
const imgData = await request.get(image);
|
||||
if (Buffer.byteLength(imgData.body) >= 2e+6) return 'size';
|
||||
const { body } = await request
|
||||
.post('https://api-us.faceplusplus.com/facepp/v3/detect')
|
||||
.attach('image_file', imgData.body)
|
||||
.query({
|
||||
api_key: FACEPLUSPLUS_KEY,
|
||||
api_secret: FACEPLUSPLUS_SECRET,
|
||||
image_url: image,
|
||||
return_attributes: 'gender,age,smiling,emotion,ethnicity,beauty'
|
||||
});
|
||||
if (!body.faces || !body.faces.length) return null;
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "119.19.5",
|
||||
"version": "119.19.6",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
@@ -62,9 +62,9 @@
|
||||
"utf-8-validate": "^5.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.4.0",
|
||||
"eslint": "^7.7.0",
|
||||
"eslint-config-amber": "^2.0.3",
|
||||
"eslint-plugin-json": "^2.1.1"
|
||||
"eslint-plugin-json": "^2.1.2"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "amber",
|
||||
|
||||
Reference in New Issue
Block a user