diff --git a/README.md b/README.md
index 8712206..cd91996 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,12 @@
-
+
# @ScathachGrip/gaebolg
**Prototype API design with only cloudflare workers and lambda functions**
-[![eslint-check](https://github.com/ScathachGrip/gaebolg/actions/workflows/build.yml/badge.svg)](https://github.com/ScathachGrip/gaebolg/actions/workflows/build.yml)
+[![Netlify Status](https://api.netlify.com/api/v1/badges/b27ff0b7-a738-4873-bd58-b9bb46cf2240/deploy-status)](https://app.netlify.com/sites/sweet-crepe-a2885e/deploys) [![eslint-check](https://github.com/ScathachGrip/gaebolg/actions/workflows/build.yml/badge.svg)](https://github.com/ScathachGrip/gaebolg/actions/workflows/build.yml)
[![Maintainability](https://api.codeclimate.com/v1/badges/76bf88b037eba8ddcd6c/maintainability)](https://codeclimate.com/github/ScathachGrip/gaebolg/maintainability)
diff --git a/package.json b/package.json
index 17abdac..37cdb4d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "gaebolg",
- "version": "6.1.10-alpha",
+ "version": "6.1.12-alpha",
"main": "index.js",
"author": "sinkaroid",
"repository": {
diff --git a/src/Base.ts b/src/Base.ts
index c646d90..f253ef2 100644
--- a/src/Base.ts
+++ b/src/Base.ts
@@ -2,5 +2,6 @@ export default {
HENTAI: "https://melony.scathach.id",
PORN: "https://tristan.scathach.id",
CUTE: "https://vlad.scathach.id",
- NASUVERSE: "https://emiya.scathach.id"
+ NASUVERSE: "https://emiya.scathach.id",
+ MINIGAMES: "https://tomoe.scathach.id"
};
\ No newline at end of file
diff --git a/src/BaseEndpoint.ts b/src/BaseEndpoint.ts
index 6bfce64..c261abc 100644
--- a/src/BaseEndpoint.ts
+++ b/src/BaseEndpoint.ts
@@ -2,5 +2,6 @@ export default {
h: "hentai",
p: "porn",
c: "cute",
- n: "nasuverse"
+ n: "nasuverse",
+ m: "minigames"
};
\ No newline at end of file
diff --git a/src/BaseImage.ts b/src/BaseImage.ts
index 9712869..a020442 100644
--- a/src/BaseImage.ts
+++ b/src/BaseImage.ts
@@ -1,9 +1,10 @@
export default {
- TYPE: ["hentai", "porn", "cute", "nasuverse"],
+ TYPE: ["hentai", "porn", "cute", "nasuverse", "minigames"],
HENTAI_IMAGE: ["3some", "69", "anal", "ass", "bdsm", "blowjob", "boobjob", "boobs", "cum", "dick_ride",
"facesit", "feet", "finger", "furry", "futa", "handjob", "hentai", "kuni", "neko", "pet",
"pussy", "sex", "solo", "spank", "strip", "tentacle", "toys", "wank", "yaoi", "yuri"],
PORN_IMAGE: ["ass", "blowjob", "boobs", "cowgirl", "cum", "doggie", "pussy", "sex"],
NASUVERSE_IMAGE: ["angry", "bonk", "cry", "happy", "hug", "kiss", "lol", "nom", "pat", "pout", "smug", "uwu", "wink"],
- CUTE_IMAGE: ["baka", "bite", "blush", "comfy", "cry", "cuddle", "dance", "feed", "fluff", "grab", "handhold", "highfive", "hug", "kiss", "lick", "neko", "pat", "poke", "punch", "slap", "smile", "smug", "stare", "tail", "tickle", "wag", "wasted", "wave", "wink"]
+ CUTE_IMAGE: ["baka", "bite", "blush", "comfy", "cry", "cuddle", "dance", "feed", "fluff", "grab", "handhold", "highfive", "hug", "kiss", "lick", "neko", "pat", "poke", "punch", "slap", "smile", "smug", "stare", "tail", "tickle", "wag", "wasted", "wave", "wink"],
+ MINIGAMES_IMAGE: ["arknights", "azurlane", "fgo", "fire_emblem", "genshin_impact", "girls_frontline", "kancolle", "vtubers"]
};
\ No newline at end of file
diff --git a/src/GaeBolg.ts b/src/GaeBolg.ts
index f1b68f6..3c13259 100644
--- a/src/GaeBolg.ts
+++ b/src/GaeBolg.ts
@@ -3,6 +3,7 @@ import { version } from "../package.json";
import base from "./Base";
import baseImage from "./BaseImage";
import baseEndpoint from "./BaseEndpoint";
+import { IGaeBolgObject, IMinigamesData } from "./interfaces";
class GaeBolg {
version: string;
@@ -11,14 +12,17 @@ class GaeBolg {
p: string;
c: string;
n: string;
+ m: string;
hentai: string;
porn: string;
cute: string;
nasuverse: string;
+ minigames: string;
hentaiImg: string[];
pornImg: string[];
cuteImg: string[];
nasuverseImg: string[];
+ minigamesImg: string[];
constructor() {
this.version = version;
this.type = baseImage.TYPE;
@@ -26,34 +30,66 @@ class GaeBolg {
this.p = baseEndpoint.p;
this.c = baseEndpoint.c;
this.n = baseEndpoint.n;
+ this.m = baseEndpoint.m;
this.hentai = base.HENTAI;
this.porn = base.PORN;
this.cute = base.CUTE;
this.nasuverse = base.NASUVERSE;
+ this.minigames = base.MINIGAMES;
this.hentaiImg = baseImage.HENTAI_IMAGE;
this.pornImg = baseImage.PORN_IMAGE;
this.cuteImg = baseImage.CUTE_IMAGE;
this.nasuverseImg = baseImage.NASUVERSE_IMAGE;
+ this.minigamesImg = baseImage.MINIGAMES_IMAGE;
}
/**
* @param {string} url
* @param {string} image
* @returns {Promise}
- * @memberof GaeBolg
- * @example const gaeBolg = new GaeBolg();
- gaeBolg.request("hentai", "yuri").then(console.log);
*/
async request(url: string, image: string): Promise {
const response = await p ({
url: `${url}/${image}/${process.env.REDACTED}`,
parse: "json"
});
+ // console.log(`${url}/${image}/${process.env.REDACTED}`);
const res = response.body as string[];
const randomData = res[Math.floor(Math.random() * res.length)];
return randomData;
}
+ /**
+ * @param {string} url
+ * @param {string} image
+ * @returns {Promise}
+ */
+ async requestObject(url: string, image: string): Promise {
+ const response = await p ({
+ url: `${url}/${image}/${process.env.REDACTED}`,
+ parse: "json"
+ });
+ const res = response.body as unknown as { data_e: string[]; data_q: string[] };
+ const rating = [res.data_e, res.data_q];
+ const randomRating = rating[Math.floor(Math.random() * rating.length)];
+
+ let isExplicit;
+ if (randomRating === res.data_e) isExplicit = "SR";
+ else isExplicit = "SSR";
+
+ const randomCharacter = randomRating[Math.floor(Math.random() * randomRating.length)] as unknown as IGaeBolgObject;
+ const randomCharacterImage = randomCharacter.image[Math.floor(Math.random() * randomCharacter.image.length)];
+ const randomCharacterTags = randomCharacter.tags.replace(/_\(.*/g, "").replace(/_/g, " ");
+
+ const minigamesData: IMinigamesData = {
+ character: this.toTitleCase(randomCharacterTags),
+ url: randomCharacterImage,
+ rating: isExplicit,
+ };
+
+ return minigamesData;
+ }
+
/**
* @param {string} word
* @returns {string | void}
@@ -64,6 +100,21 @@ class GaeBolg {
}
}
+ /**
+ * @param {string} str
+ * @returns {string}
+ */
+
+ toTitleCase(str: string): string {
+ return str.replace(
+ /\w\S*/g,
+ function(txt) {
+ txt = txt.replace(/_/g, " ");
+ return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
+ }
+ );
+ }
+
/**
* @param {string} err
* @param {string | null} ua
diff --git a/src/index.ts b/src/index.ts
index 5277c0b..79e7e64 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -4,12 +4,12 @@ import RateLimiter from "async-ratelimiter";
import Redis from "ioredis";
import { getClientIp } from "request-ip";
import { APIGatewayEvent } from "aws-lambda";
-import { successDelivered, errorNoParams, errorTagsParams, rateLimitHit } from "./utils/handler";
+import { successDelivered, successDeliveredObject, errorNoParams, errorTagsParams, rateLimitHit } from "./utils/handler";
import { iParams } from "./constant/data";
const rateLimiter = new RateLimiter({
db: new Redis(process.env.REDIS_URL as string),
- max: 3,
+ max: 5,
duration: 10000
});
@@ -35,6 +35,9 @@ export async function handler(
else if (gateway.specs.type === gaeBolg.n
&& !gaeBolg.nasuverseImg.includes(gateway.specs.image)) return errorTagsParams(gaeBolg.n);
+ else if (gateway.specs.type === gaeBolg.m
+ && !gaeBolg.minigamesImg.includes(gateway.specs.image)) return errorTagsParams(gaeBolg.m);
+
else {
try {
//const user = event.headers["client-ip"] as string;
@@ -51,9 +54,16 @@ export async function handler(
baseUrl = gaeBolg.cute, image = gateway.specs.image;
else if (gateway.specs.type === gaeBolg.n)
baseUrl = gaeBolg.nasuverse, image = gateway.specs.image;
+ else if (gateway.specs.type === gaeBolg.m)
+ baseUrl = gaeBolg.minigames, image = gateway.specs.image;
- const response = await gaeBolg.request(baseUrl, image);
- return successDelivered(response, userAgent);
+ if (baseUrl !== gaeBolg.minigames) {
+ const response = await gaeBolg.request(baseUrl, image);
+ return successDelivered(response, userAgent);
+ } else {
+ const response = await gaeBolg.requestObject(baseUrl, image);
+ return successDeliveredObject(response, userAgent);
+ }
}
} catch (e) {
diff --git a/src/interfaces.ts b/src/interfaces.ts
new file mode 100644
index 0000000..42b8b9c
--- /dev/null
+++ b/src/interfaces.ts
@@ -0,0 +1,10 @@
+export interface IMinigamesData {
+ character: string;
+ url: string;
+ rating: string;
+}
+
+export interface IGaeBolgObject {
+ tags: string;
+ image: string[];
+}
\ No newline at end of file
diff --git a/src/utils/handler.ts b/src/utils/handler.ts
index 2a93279..35baeeb 100644
--- a/src/utils/handler.ts
+++ b/src/utils/handler.ts
@@ -24,6 +24,10 @@ export async function errorNoParams(ua: string | null) {
{
type: "nasuverse",
image: gaeBolg.nasuverseImg
+ },
+ {
+ type: "minigames",
+ image: gaeBolg.minigamesImg
}
],
message: "You didn't provide any parameters or it's invalid",
@@ -74,6 +78,20 @@ export async function successDelivered(url: string, userAgent: string | null) {
};
}
+export async function successDeliveredObject(data: object, userAgent: string | null) {
+ return {
+ statusCode: 200,
+ headers: {
+ "Content-Type": "application/json"
+ },
+ body: JSON.stringify({
+ success: true,
+ data: data,
+ user_agent: userAgent
+ })
+ };
+}
+
export function rateLimitHit(userAgent: string | null, ip: string | null): object {
return {
statusCode: 429,