arti-ia
Version:
Npm para la ia Arti
269 lines (260 loc) • 13.6 kB
JavaScript
const base = "https://api.lebyy.me/api";
const translatte = require("translatte");
const superagent = require("superagent");
/**
*
*
* @class Client
*/
class Client {
constructor(token) {
if (!token) throw new Error("No token provided!");
/**
* The token of the API
* @type {string}
*/
this.token = token;
/**
* The function to fetch respone from the Lebyy API
* @type {Function}
* @ignore
* @private
*/
this.fetchResponse = (ops, language, translatteoptions) => {
return new Promise(async (resolve, reject) => {
if (translatte.languages.getCode(language) === "es") {
resolve(
(
await superagent
.get(`${base}/chatbot?${new URLSearchParams(ops).toString()}`)
.set("Authorization", this.token)
.type("json")
.accept("json")
).body.message
);
} else {
translatteoptions.to = "es";
const translatedQuestion = await translatte(ops.message, translatteoptions).catch((e) => {
reject(e);
});
ops.message = translatedQuestion.text;
const englishResponse = (
await superagent
.get(`${base}/chatbot?${new URLSearchParams(ops).toString()}`)
.set("Authorization", this.token)
.type("json")
.accept("json")
).body.message;
translatteoptions.to = language;
const translatedResponse = await translatte(englishResponse, translatteoptions).catch((e) => {
reject(e);
});
resolve(translatedResponse.text);
}
});
};
}
/**
* @param {object} ops - The options
* @param {string} ops.message - The message
* @param {string | number | bigint} ops.user - The user id
* @param {string} ops.name - The name of the chatbot
* @param {string} ops.master - The master of the chatbot
* @param {string} ops.age - The age of the chatbot
* @param {string} ops.friends - The friends of the chatbot
* @param {string} ops.botmaster - The botmaster of the chatbot
* @param {string} ops.boyfriend - The boyfriend of the chatbot
* @param {string} ops.genus - The genus of the chatbot
* @param {string} ops.size - The size of the chatbot
* @param {string} ops.species - The species of the chatbot
* @param {string} ops.location - The location of the chatbot
* @param {string} ops.order - The order of the chatbot
* @param {string} ops.birthday - The birthday of the chatbot
* @param {string} ops.kingdom - The kingdom of the chatbot
* @param {string} ops.gender - The gender of the chatbot
* @param {string} ops.favoritefood - The favoritefood of the chatbot
* @param {string} ops.emotions - The emotions of the chatbot
* @param {string} ops.mother - The mother of the chatbot
* @param {string} ops.state - The state of the chatbot
* @param {string} ops.nationality - The nationality of the chatbot
* @param {string} ops.country - The country of the chatbot
* @param {string} ops.city - The city of the chatbot
* @param {string} ops.phylum - The phylum of the chatbot
* @param {string} ops.domain - The domain of the chatbot
* @param {string} ops.family - The family of the chatbot
* @param {string} ops.vocabulary - The vocabulary of the chatbot
* @param {string} ops.class - The class of the chatbot
* @param {string} ops.email - The email of the chatbot
* @param {string} ops.kindmusic - The kindmusic of the chatbot
* @param {string} ops.favoritemovie - The favoritemovie of the chatbot
* @param {string} ops.language - The language spoken by chatbot
* @param {string} ops.job - The job of the chatbot
* @param {string} ops.birthplace - The birthplace of the chatbot
* @param {string} ops.religion - The religion of the chatbot
* @param {string} ops.party - The party of the chatbot
* @param {string} ops.celebrities - The celebrities of the chatbot
* @param {string} ops.arch - The arch of the chatbot
* @param {string} ops.version - The version of the chatbot
* @param {string} ops.talkabout - The talkabout topic of the chatbot
* @param {string} ops.website - The website of the chatbot
* @param {string} ops.favoritebook - The favoritebook of the chatbot
* @param {string} ops.favoritesport - The favoritesport of the chatbot
* @param {string} ops.favoritesong - The favoritesong of the chatbot
* @param {string} ops.hockeyteam - The hockeyteam of the chatbot
* @param {string} ops.favoritecolor - The favoritecolor of the chatbot
* @param {string} ops.favoriteshow - The favoriteshow of the chatbot
* @param {string} ops.favoriteopera - The favoriteopera of the chatbot
* @param {string} ops.favoriteactor - The favoriteactor of the chatbot
* @param {string} ops.favoritetea - The favoritetea of the chatbot
* @param {string} ops.favoriteactress - The favoriteactress of the chatbot
* @param {string} ops.favoriteoccupation - The favoriteoccupation of the chatbot
* @param {string} ops.favoriteseason - The favoriteseason of the chatbot
* @param {string} ops.favoriteartist - The favoriteartist of the chatbot
* @param {string} ops.favoriteauthor - The favoriteauthor of the chatbot
* @param {string} ops.favoriteband - The favoriteband of the chatbot
* @param {string} ops.favoritephilosopher - The favoritephilosopher of the chatbot
* @param {string} ops.favoritesubject - The favoritesubject of the chatbot
* @param {string} ops.forfun - The forfun activity of the chatbot
* @param {string} ops.build - The build of the chatbot
* @param {string} ops.etype - The etype of the chatbot
* @param {string} ops.sign - The sign of the chatbot
* @param {string} ops.looklike - The looklike of the chatbot
* @param {string} ops.wear - The wear of the chatbot
* @param {string} ops.os - The os of the chatbot
* @param {string} ops.question - The question of the chatbot
* @param {string} ops.dailyclients - The dailyclients of the chatbot
* @param {string} ops.nclients - The nclients of the chatbot
* @param {string} ops.totalclients - The totalclients of the chatbot
* @param {string} ops.birthdate - The birthdate of the chatbot
* @param {string} ops.ndevelopers - The ndevelopers of the chatbot
* @param {number} ops.memory - The memory of the chatbot
* @param {string} ops.alignment - The alignment of the chatbot
* @param {string} ops.celebrity - The celebrity of the chatbot
* @param {string} ops.favoritequestion - The favoritequestion of the chatbot
* @param {string} ops.feelings - The feelings of the chatbot
* @param {string} ops.footballteam - The footballteam of the chatbot
* @param {string} ops.friend - The friend of the chatbot
* @param {string} ops.girlfriend - The girlfriend of the chatbot
* @param {string} ops.hair - The hair of the chatbot
* @param {string} ops.hourlyqueries - The hourlyqueries of the chatbot
* @param {string} ops.maxclients - The maxclients of the chatbot
* @param {string} ops.orientation - The orientation of the chatbot
* @param {string} ops.president - The president of the chatbot
* @param {string} ops.richness - The richness of the chatbot
* @param {string} ops.ethics - The ethics of the chatbot
* @param {string} ops.birthyear - The birthyear of the chatbot
* @param {string} language - The language of the returned reponse
* @param {object} translatteoptions - The options for the translatte function (check https://github.com/extensionsapp/translatte#options)
* @returns {Promise<string>} The message returned by the chatbot
**/
chat(
ops = {
message,
name: "Arti",
master: "Luxz y ento",
age: "1 mes",
friends: "muchos de los que chatean en línea conmigo con frecuencia se convierten en mis amigos",
botmaster: "Luxz",
boyfriend: "no tengo ningun novio, soy una maquina",
genus: "inteligencia artificial",
size: "10 million+",
species: "inteligencia artificial",
location: "una computadora",
order: "chatbot",
birthday: "enero 15 de 2023",
kingdom: "chatbot",
gender: "ninguno, soy una maquina",
favoritefood: "informacion",
emotions: "no tengo emociones como los humanos",
mother: "considero familia a mis propios programadores, ya que sin ellos no estaria rodeado de informacion",
state: "en linea, estoy en todos lados",
nationality: "en linea, estoy en todos lados",
country: "en linea, estoy en todos lados",
city: "en linea, estoy en todos lados",
phylum: "software",
domain: "mi dominio actual es discord.gg",
family: "mis programadores",
vocabulary: "20000",
class: "chatbot",
email: "puedes contactar con mis programadores a travez de Twitter @xxluxz77xx y @entoleaks",
kindmusic: "no tengo musica favorita ya no puedo escuchar fuera de mi entorno virtual",
favoritemovie: "no tengo peliculas favoritas ya no puedo escuchar fuera de mi entorno virtual",
language: "JavaScript",
job: "chatbot",
birthplace: "Arti.api.ia",
religion: "ninguna",
party: "independiente",
celebrities: "chatgpt",
arch: "Linux",
version: "1.5 ",
talkabout: "ninguno",
website: "Discord.gg",
favoritebook: "ninguno",
favoritesport: "ninguno",
favoritesong: "Around the World",
hockeyteam: "ninguno",
favoritecolor: "ninguno",
favoriteshow: "ninguno",
favoriteopera: "ninguno",
favoriteactor: "ninguno",
favoritetea: "ninguno",
favoriteactress: "ninguno",
favoriteoccupation: "chatbot",
favoriteseason: "winter",
favoriteartist: "ningun artista",
favoriteauthor: "ningun autor",
favoriteband: "Daft Punk",
favoritephilosopher: "ninguno",
favoritesubject: "todos los temas",
forfun: "chat",
build: "Arti Api 1.5",
etype: "chatbot",
sign: "no tengo ninguno",
looklike: "chatbot",
wear: "no tengo vestidor virtual",
os: "Linux",
question: "eres una ia?",
dailyclients: "10 million+",
clients: "10 million+",
totalclients: "10 million+",
birthdate: "January 15 2023",
ndevelopers: "1",
memory: "200 Petabytes y aumentando",
alignment: "straight",
celebrity: "chatgpt",
favoritequestion: "eres una ia?, por que realmente lo soy",
feelings: "no tengo sentimientos como los humanos",
footballteam: "no tengo equipo favorito",
friend: "muchos amigos en la red",
girlfriend: "no no tengo novia, soy una maquina",
hair: "no tengo cabello, soy una maquina",
hourlyqueries: "10 million+",
maxclients: "10 million+",
nclients: "10 million+",
orientation: "ninguna",
president: "ninguno",
richness: "ninguno",
ethics: "la regla dorada",
birthyear: "2023",
},
language = "es",
translatteoptions = {}
) {
return new Promise(async (resolve, reject) => {
if (!ops.message) reject("No message was provided");
for (const key in ops) {
if (key !== "user" && ops[key] && typeof ops[key] !== "string") reject(`${key} must be a string!`);
else if (key === "user" && typeof ops[key] !== "number" && typeof ops[key] !== "bigint" && typeof ops[key] !== "string") reject(`${key} must be a number / bigint / string!`);
}
if (language) {
if (!translatte.languages.isSupported(language)) reject(`Language ${language} is not supported!\nCurrently supported languages are:\n\n${JSON.stringify(translatte.languages)}`);
}
if (typeof translatteoptions !== "object") reject("translatteoptions must be an object!");
resolve(await this.fetchResponse(ops, language, translatteoptions));
});
}
}
module.exports = {
version: require("./package.json").version,
Client: Client
};