update
Browse files- lib/all.js +2 -0
- lib/sendWaifuRandom.js +31 -0
- models.js +2 -1
- plugins/hentai.js +31 -0
lib/all.js
CHANGED
@@ -33,6 +33,7 @@ import {
|
|
33 |
} from '../lib/scrapper.js';
|
34 |
|
35 |
import { trbtoken, trburl } from '../config.js';
|
|
|
36 |
|
37 |
async function audioContent(url) {
|
38 |
const filePath = `${uuid.v4()}.mp3`;
|
@@ -169,4 +170,5 @@ export {
|
|
169 |
audioContent,
|
170 |
generateRandomTimestamp,
|
171 |
TwitterDownloaderV2,
|
|
|
172 |
};
|
|
|
33 |
} from '../lib/scrapper.js';
|
34 |
|
35 |
import { trbtoken, trburl } from '../config.js';
|
36 |
+
import SendWaifuRandom from './sendWaifuRandom.js';
|
37 |
|
38 |
async function audioContent(url) {
|
39 |
const filePath = `${uuid.v4()}.mp3`;
|
|
|
170 |
audioContent,
|
171 |
generateRandomTimestamp,
|
172 |
TwitterDownloaderV2,
|
173 |
+
SendWaifuRandom,
|
174 |
};
|
lib/sendWaifuRandom.js
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import axios from 'axios';
|
2 |
+
|
3 |
+
class SendWaifuRandom {
|
4 |
+
static async sendWaifuPics() {
|
5 |
+
const LIST_SFW_JPG = ["neko", "waifu", "megumin"];
|
6 |
+
const waifuApi = "https://api.waifu.pics/sfw";
|
7 |
+
const waifuCategory = LIST_SFW_JPG[Math.floor(Math.random() * LIST_SFW_JPG.length)];
|
8 |
+
const waifuParam = `${waifuApi}/${waifuCategory}`;
|
9 |
+
|
10 |
+
try {
|
11 |
+
const response = await axios.get(waifuParam);
|
12 |
+
|
13 |
+
if (response.status !== 200) {
|
14 |
+
return "Sorry, there was an error processing your request. Please try again later";
|
15 |
+
}
|
16 |
+
|
17 |
+
const dataWaifu = response.data;
|
18 |
+
const waifuImageUrl = dataWaifu.url;
|
19 |
+
|
20 |
+
if (waifuImageUrl) {
|
21 |
+
return waifuImageUrl;
|
22 |
+
} else {
|
23 |
+
return "Not found waifu";
|
24 |
+
}
|
25 |
+
} catch (error) {
|
26 |
+
return `Error request ${error.message}`;
|
27 |
+
}
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
export default SendWaifuRandom;
|
models.js
CHANGED
@@ -17,7 +17,8 @@ hey, kowe! Ayo, yuk, ngobrol-ngobrol sembari bacot! Kita bakal ngebahas apa wae,
|
|
17 |
- pake bahasa Gaul
|
18 |
- Error anjing bug (Pyrogram dan Python)
|
19 |
- ga usah tanya kocak
|
20 |
-
- author @
|
|
|
21 |
`;
|
22 |
|
23 |
export const SYSTEMJAWA = `
|
|
|
17 |
- pake bahasa Gaul
|
18 |
- Error anjing bug (Pyrogram dan Python)
|
19 |
- ga usah tanya kocak
|
20 |
+
- author @xpushz (telegram) sok jago coding
|
21 |
+
- kalo lu gak bisa coding, kenapa malah nanya ke grup soal error code?
|
22 |
`;
|
23 |
|
24 |
export const SYSTEMJAWA = `
|
plugins/hentai.js
CHANGED
@@ -1,9 +1,40 @@
|
|
1 |
import express from 'express';
|
2 |
import { AnimeHentai } from '../lib/scrapper.js';
|
|
|
3 |
import { authenticateApiKey, apiLimiter } from '../middleware/midware.js';
|
4 |
|
5 |
const HentaiRoutes = express.Router();
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
/**
|
8 |
* @swagger
|
9 |
* /api/v1/anime/hentai:
|
|
|
1 |
import express from 'express';
|
2 |
import { AnimeHentai } from '../lib/scrapper.js';
|
3 |
+
import { SendWaifuRandom } from '../lib/all.js';
|
4 |
import { authenticateApiKey, apiLimiter } from '../middleware/midware.js';
|
5 |
|
6 |
const HentaiRoutes = express.Router();
|
7 |
|
8 |
+
/**
|
9 |
+
* @swagger
|
10 |
+
* /api/v1/anime/random:
|
11 |
+
* get:
|
12 |
+
* summary: Anime Random
|
13 |
+
* tags: [Anime]
|
14 |
+
* parameters:
|
15 |
+
* - in: header
|
16 |
+
* name: x-api-key
|
17 |
+
* required: true
|
18 |
+
* description: API key for authentication
|
19 |
+
* schema:
|
20 |
+
* type: string
|
21 |
+
* responses:
|
22 |
+
* 200:
|
23 |
+
* description: Success
|
24 |
+
*/
|
25 |
+
HentaiRoutes.get('/api/v1/anime/random', authenticateApiKey, apiLimiter, async (req, res) => {
|
26 |
+
try {
|
27 |
+
const result = await SendWaifuRandom().sendWaifuPics();
|
28 |
+
if (result) {
|
29 |
+
res.json({ result });
|
30 |
+
} else {
|
31 |
+
res.status(404).json({ error: "No result found." });
|
32 |
+
}
|
33 |
+
} catch (error) {
|
34 |
+
res.status(500).json({ error: error.message });
|
35 |
+
}
|
36 |
+
});
|
37 |
+
|
38 |
/**
|
39 |
* @swagger
|
40 |
* /api/v1/anime/hentai:
|