This commit is contained in:
Lukian LEIZOUR 2022-11-28 20:19:22 +01:00
parent 1bbbf05545
commit ba0ebec07d
10 changed files with 110 additions and 40 deletions

View file

@ -60,4 +60,22 @@ function addToLogs(message) {
});
}
module.exports = { addToLogs, isTrue, image_search };
function getHelp(commandName, ctx, bot) {
const commands = [ 'images', 'games', 'r34', 'openai', 'tools' ];
const commandsPaths = { 'images': './src/helps/images.txt', 'games': './src/helps/games.txt', 'r34': './src/helps/r34.txt', 'openai': './src/helps/openAI.txt', 'tools': './src/helps/tools.txt' };
if (commands.includes(commandName)) {
fs.readFile(commandsPaths[commandName], 'utf8', (err, data) => {
if (err) {
console.log(err);
bot.telegram.sendMessage(ctx.chat.id, "Something went wrong", {});
} else {
bot.telegram.sendMessage(ctx.chat.id, data, {parse_mode: 'Markdown'});
}
});
} else {
bot.telegram.sendMessage(ctx.chat.id, "This command doesn't exist", {});
}
}
module.exports = { addToLogs, isTrue, image_search, getHelp };

View file

@ -13,10 +13,14 @@ function generateImage(query, ctx, bot) {
n: 1,
size: "1024x1024",
response_format : 'url'
})
}).catch((err) => {
console.log(err);
addToLogs("--> error : " + err);
bot.telegram.sendMessage(ctx.chat.id, "Something went wrong", {});
});
console.log("--> generating image for the querry" + query);
addToLogs("--> generating image for the querry" + query)
console.log("--> generating image for the querry " + query);
addToLogs("--> generating image for the querry " + query)
bot.telegram.sendMessage(ctx.chat.id, "Generating the image.", {});
image.then((res) => {

View file

@ -6,10 +6,15 @@ const https = require('https');
const { addToLogs } = require('./botTools');
const blockedChannels = [ -1001845876532 ];
function rtag(query, ctx, bot) {
//
//Search for a tag on r34
//
if (blockedChannels.includes(ctx.chat.id)) {
bot.telegram.sendMessage(ctx.chat.id, "This command is disabled in this channel", {});
return;
}
console.log("--> r34sTag query: " + query);
addToLogs("--> r34sTag query: " + query);
https.get("https://rule34.xxx/public/autocomplete.php?q=" + query, (resp) => {
@ -47,6 +52,11 @@ function r34(tag, ctx, bot) {
//
//Search for the tag on r34 and send a random image
//
if (blockedChannels.includes(ctx.chat.id)) {
bot.telegram.sendMessage(ctx.chat.id, "This command is disabled in this channel", {});
return;
}
console.log("--> r34 query: " + tag);
addToLogs("--> r34 query: " + tag);
https.get('https://api.rule34.xxx/index.php?page=dapi&s=post&q=index&json=1&tags=' + tag, (resp) => {