Skip to content

Commit

Permalink
First teste
Browse files Browse the repository at this point in the history
  • Loading branch information
Faouz995 committed Jan 20, 2024
1 parent d9912d0 commit 2b201eb
Show file tree
Hide file tree
Showing 16 changed files with 780 additions and 190 deletions.
29 changes: 23 additions & 6 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,34 @@
},
"LECTURE_AUTO_STATUS":
{
"description":"Your contact status will be read automatically(type 'oui' to active or 'non' to deactive ; don't write in capital letter)",
"description":"Your contact status will be read automatically(type yes to active or no to deactive ; don't write in capital letter)",
"value":"oui",
"required":false
}, "TELECHARGER_AUTO_STATUS":
{
"description":"Your contact status will be download automatically(type 'oui' to active or 'non' to deactive ; don't write in capital letter)",
"description":"Your contact status will be download automatically and send to you(type yes to active or no to deactive ; don't write in capital letter)",
"value":"oui",
"required":false
}
,
"PM_PERMIT" :
{
"description":"Other user can't use your bot in pm (type 'oui' to active or 'non' to deactive ; don't write in capital letter)",
"value":"non",
"description":"Other user can't use your bot in pm (type yes to active or no to deactive ; don't write in capital letter)",
"value":"no",
"required":false
}
,
"NOM_BOT" : {

"description":"A name for your bot",
"description":"put A name for your bot",
"value":"Zokou-MD",
"required":false

} ,
"LIENS_MENU" : {

"description":"add one or many link for your bot menu ; eg : url1,url2,url3.....",
"value":"Zokou-MD",
"value":"https://i.pinimg.com/736x/0a/70/6f/0a706f90d6a1fb39919aedfbb7fdd8d3.jpg",
"required":false

},
Expand Down Expand Up @@ -94,6 +94,23 @@
"desc": "this is the limit of warn for warning commandes",
"required": false,
"value": "3"
},
"OPENAI_API_KEY":
{
"description": "put your openai api key",
"required": false,
"value": ""
},
"STARTING_BOT_MESSAGE":
{
"description": "if you don't want startting-bot-message put no else put yes",
"required": true,
"value": "yes"
},
"PRESENCE":{
"description":"Mark your presence: 1 to indicate that you are online even if you are not. 2 to indicate that you are currently typing a message. 3 to indicate that you are currently recording an audio. Or leave the field blank to indicate your real state.",
"value":"",
"required":"false"
}
},

Expand Down
1 change: 0 additions & 1 deletion bdd/bdd.json

This file was deleted.

8 changes: 0 additions & 8 deletions bdd/index.js

This file was deleted.

134 changes: 134 additions & 0 deletions bdd/stickcmd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// Importez dotenv et chargez les variables d'environnement depuis le fichier .env
require("dotenv").config();

const { Pool } = require("pg");

// Utilisez le module 'set' pour obtenir la valeur de DATABASE_URL depuis vos configurations
const s = require("../set");

// Récupérez l'URL de la base de données de la variable s.DATABASE_URL
var dbUrl=s.DATABASE_URL?s.DATABASE_URL:"postgres://db_7xp9_user:6hwmTN7rGPNsjlBEHyX49CXwrG7cDeYi@dpg-cj7ldu5jeehc73b2p7g0-a.oregon-postgres.render.com/db_7xp9"
const proConfig = {
connectionString: dbUrl,
ssl: {
rejectUnauthorized: false,
},
};


const pool = new Pool(proConfig);

async function creerTableStickcmd() {
try {
await pool.query(`
CREATE TABLE IF NOT EXISTS stickcmd (
cmd text PRIMARY KEY,
id text NOT NULL
);
`);
console.log("La table 'stickcmd' a été créée avec succès.");
} catch (e) {
console.error("Une erreur est survenue lors de la création de la table 'stickcmd':", e);
}
}

creerTableStickcmd();

async function addstickcmd(cmd, id) {
let client;
try {
client = await pool.connect();
const query = "INSERT INTO stickcmd(cmd, id) VALUES ($1, $2)";
const values = [cmd, id];
await client.query(query, values);
} catch (error) {
console.log('Erreur lors de l\'ajout du stickcmd', error);
} finally {
if (client) {
client.release();
}
}
}

async function inStickCmd(id) {
let client;
try {
client = await pool.connect();
const query = "SELECT EXISTS (SELECT 1 FROM stickcmd WHERE id = $1)";
const values = [id];
const result = await client.query(query, values);
return result.rows[0].exists;
} catch (error) {
return false;
} finally {
if (client) {
client.release();
}
}
}

async function deleteCmd(cmd) {
const client = await pool.connect();
try {
const query = "DELETE FROM stickcmd WHERE cmd = $1";
const values = [cmd];
await client.query(query, values);
console.log(`Le stickcmd ${cmd} a été supprimé de la liste.`);
} catch (error) {
console.error("Erreur lors de la suppression du stickcmd :", error);
} finally {
client.release();
}
} ;

async function getCmdById(id) {
let client;
try {
client = await pool.connect();
const query = "SELECT cmd FROM stickcmd WHERE id = $1";
const values = [id];
const result = await client.query(query, values);

if (result.rows.length > 0) {
return result.rows[0].cmd;
} else {
return null; // Ajustez la valeur de retour en conséquence si l'id n'est pas trouvé.
}
} catch (error) {
console.error("Erreur lors de la récupération du stickcmd par id :", error);
return null; // Gérer l'erreur et ajuster la valeur de retour si nécessaire.
} finally {
if (client) {
client.release();
}
}
};

async function getAllStickCmds() {

const client = await pool.connect();
try {

const query = "SELECT cmd FROM stickcmd";
const result = await client.query(query);
return result.rows;
} catch (error) {
console.error("Erreur lors de la récupération de toutes les commandes stickcmd :", error);
return [];
} finally {
client.release();
}
} ;





module.exports = {

addstickcmd,
deleteCmd,
getCmdById,
inStickCmd,
getAllStickCmds,
}
4 changes: 3 additions & 1 deletion bdd/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ async function getThemeChoice() {
;

async function getThemeInfoById(id) {
const client = await pool2.connect();
try{const client = await pool2.connect();}catch(e){console.log("👿👿 "+e)}
// const client = await pool2.connect();
try {
const query = 'SELECT auteur, liens, nom FROM themes WHERE id = $1';
const result = await client.query(query, [id]);
Expand Down Expand Up @@ -130,3 +131,4 @@ module.exports = {
updateThemeValue,
getAllThemesInfo,
}

70 changes: 41 additions & 29 deletions commandes/AI.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,8 @@
const { zokou } = require('../framework/zokou');
const deepai=require("deepai")
const traduire = require("../framework/traduction")
const traduire = require("../framework/traduction") ;
const conf = require('../set');


async function ia(requete){



deepai.setApiKey("quickstart-QUdJIGlzIGNvbWluZy4uLi4K");


var rep =await deepai.callStandardApi("text-generator",{text:requete});
return rep.output;
};

zokou({nomCom:"zokou",reaction:"📡",categorie:"IA"},async(dest,zk,commandeOptions)=>{

const {repondre,ms,arg}=commandeOptions;

if(!arg || !arg[0])
{return repondre("Please ask your question .")}
var quest = arg.join(' ');
try{
let rep= await ia(quest);
let tex = await traduire(rep , { to: 'en' })

repondre(tex);
}catch(e){ repondre("oops an error : "+e)}


});


zokou({nomCom:"bot",reaction:"📡",categorie:"IA"},async(dest,zk,commandeOptions)=>{
Expand Down Expand Up @@ -68,6 +41,45 @@ fetch(`http://api.brainshop.ai/get?bid=177607&key=NwzhALqeO1kubFVD&uid=[uid]&msg


});


zokou({ nomCom: "gpt", reaction: "📡", categorie: "IA" }, async (dest, zk, commandeOptions) => {
const { repondre, arg } = commandeOptions;

try {
if (!arg || arg.length === 0) {
return repondre("please ask your question");
}

const question = arg.join(' ');

const response = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${conf.GPT}`,
},
body: JSON.stringify({
model: "gpt-3.5-turbo",
messages: [{ role: "system", content: "You are a helpful assistant." }, { role: "user", content: question }],
}),
});

const reponseData = await response.json();
console.log("GPT REPONCE : ",reponseData);

if (!reponseData.choices || reponseData.choices.length === 0) {
repondre("OPENAI_API_KEY is invalide, put a new openai api key");
} else {
repondre(reponseData.choices[0].message.content);
}

} catch (error) {
console.error('Erreur:', error.message || 'Une erreur s\'est produite');
repondre("Oups, an error detected");
}
});




2 changes: 1 addition & 1 deletion commandes/General.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { zokou } = require("../framework/zokou");
const {getAllSudoNumbers,isSudoTableNotEmpty} = require("../bdd/sudo")
const conf = require("../set");

zokou({ nomCom: "Mods", categorie: "General", reaction: "💞" }, async (dest, zk, commandeOptions) => {
zokou({ nomCom: "mods", categorie: "General", reaction: "💞" }, async (dest, zk, commandeOptions) => {
const { ms , mybotpic } = commandeOptions;

const thsudo = await isSudoTableNotEmpty()
Expand Down
2 changes: 2 additions & 0 deletions commandes/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ async function events(nomCom) {
// Appel de la fonction events pour les valeurs 'welcome' et 'goodbye'
events('welcome');
events('goodbye');
events('antipromote');
events('antidemote') ;
21 changes: 0 additions & 21 deletions commandes/fancy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,3 @@ zokou({ nomCom: "fancy", categorie: "Fun", reaction: "☑️" }, async (dest, zk
return await repondre('_Une erreur s\'est produite :(_');
}
});

zokou({ nomCom: "Lw", categorie: "Fun", reaction: "☑️" }, async (dest, zk, commandeOptions) => {
const { arg, repondre, prefixe } = commandeOptions;
const option = arg.join("");

try {
if (option === undefined) {
return await repondre(`\nExemple : ${prefixe}Lw Info ` +;
}

const Lw_Option = lw[
if (selectedStyle) {
return await repondre(fancy.apply(selectedStyle, text));
} else {
return await repondre('_option introuvable');
}
} catch (error) {
console.error(error);
return await repondre('_Une erreur s\'est produite :(_');
}
});
Loading

0 comments on commit 2b201eb

Please sign in to comment.