commit
This commit is contained in:
parent
1bbbf05545
commit
ba0ebec07d
10 changed files with 110 additions and 40 deletions
52
app.js
52
app.js
|
@ -1,10 +1,11 @@
|
||||||
//Importing libs
|
//Importing libs
|
||||||
const { Telegraf } = require('telegraf');
|
const { Telegraf } = require('telegraf');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
//Importing other files
|
//Importing other files
|
||||||
const { getJoke } = require('./libs/dadJokes');
|
const { getJoke } = require('./libs/dadJokes');
|
||||||
const { rtag, r34 } = require('./libs/rule34');
|
const { rtag, r34 } = require('./libs/rule34');
|
||||||
const { addToLogs, isTrue, image_search } = require('./libs/botTools');
|
const { addToLogs, isTrue, image_search, getHelp } = require('./libs/botTools');
|
||||||
const { rockPaperScissorsAgainstBot } = require('./libs/games');
|
const { rockPaperScissorsAgainstBot } = require('./libs/games');
|
||||||
const { generateImage } = require('./libs/openAi');
|
const { generateImage } = require('./libs/openAi');
|
||||||
|
|
||||||
|
@ -18,36 +19,19 @@ bot.command('start', ctx => {
|
||||||
addToLogs("--> sent the start message to " + ctx.message.from.username);
|
addToLogs("--> sent the start message to " + ctx.message.from.username);
|
||||||
})
|
})
|
||||||
|
|
||||||
bot.help(ctx => {
|
bot.command('help', ctx => {
|
||||||
const helpMessage =
|
if (ctx.message.text.slice(+6) != '') {
|
||||||
`
|
getHelp(ctx.message.text.slice(+6), ctx, bot);
|
||||||
This is the help message :
|
} else {
|
||||||
Help command :
|
fs.readFile('./src/helps/default.txt', 'utf8', (err, data) => {
|
||||||
-/help
|
if (err) {
|
||||||
Anime command :
|
console.log(err);
|
||||||
-/anime
|
bot.telegram.sendMessage(ctx.chat.id, "Something went wrong", {});
|
||||||
AI Generated image command :
|
} else {
|
||||||
-\`/g <query>\`
|
bot.telegram.sendMessage(ctx.chat.id, data, {parse_mode: 'Markdown'});
|
||||||
Image search command :
|
}
|
||||||
-\`/s <query>\`
|
});
|
||||||
Dad jokes command :
|
}
|
||||||
-/dadjoke
|
|
||||||
Rock Paper Scissors command :
|
|
||||||
-\`/rps <rock/paper/scissors>\`
|
|
||||||
Rule34 tag command :
|
|
||||||
-\`/rtag <querry>\`
|
|
||||||
Rule 34 image search :
|
|
||||||
-\`/r34 <tag>\`
|
|
||||||
Truce command :
|
|
||||||
-/truce (reply to a message with that command to verify it)
|
|
||||||
Suggest command :
|
|
||||||
-\`/suggest <suggestion>\` (allows you to add a suggestion to the chanel t.me/+SrzC81CGyusyODNk)
|
|
||||||
Github link command :
|
|
||||||
-/github
|
|
||||||
`
|
|
||||||
bot.telegram.sendMessage(ctx.chat.id, helpMessage, {parse_mode: "Markdown"})
|
|
||||||
console.log('--> sent the help message')
|
|
||||||
addToLogs('--> sent the help message')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
bot.command('anime', ctx => {
|
bot.command('anime', ctx => {
|
||||||
|
@ -70,8 +54,10 @@ bot.command('truce', ctx => {
|
||||||
isTrue(ctx.update.message.reply_to_message.text, ctx, bot)
|
isTrue(ctx.update.message.reply_to_message.text, ctx, bot)
|
||||||
})
|
})
|
||||||
|
|
||||||
bot.command('chatInfo', ctx => {
|
bot.command('chatinfo', ctx => {
|
||||||
console.log(ctx.chat.id)
|
console.log('--> sent chat info')
|
||||||
|
addToLogs('--> sent chat info')
|
||||||
|
bot.telegram.sendMessage(ctx.chat.id, 'Chat id : ' + ctx.chat.id, {})
|
||||||
})
|
})
|
||||||
|
|
||||||
bot.command('suggest', ctx => {
|
bot.command('suggest', ctx => {
|
||||||
|
|
|
@ -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 };
|
|
@ -13,7 +13,11 @@ function generateImage(query, ctx, bot) {
|
||||||
n: 1,
|
n: 1,
|
||||||
size: "1024x1024",
|
size: "1024x1024",
|
||||||
response_format : 'url'
|
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);
|
console.log("--> generating image for the querry " + query);
|
||||||
addToLogs("--> generating image for the querry " + query)
|
addToLogs("--> generating image for the querry " + query)
|
||||||
|
|
|
@ -6,10 +6,15 @@ const https = require('https');
|
||||||
|
|
||||||
const { addToLogs } = require('./botTools');
|
const { addToLogs } = require('./botTools');
|
||||||
|
|
||||||
|
const blockedChannels = [ -1001845876532 ];
|
||||||
|
|
||||||
function rtag(query, ctx, bot) {
|
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);
|
console.log("--> r34sTag query: " + query);
|
||||||
addToLogs("--> r34sTag query: " + query);
|
addToLogs("--> r34sTag query: " + query);
|
||||||
https.get("https://rule34.xxx/public/autocomplete.php?q=" + query, (resp) => {
|
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
|
//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);
|
console.log("--> r34 query: " + tag);
|
||||||
addToLogs("--> 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) => {
|
https.get('https://api.rule34.xxx/index.php?page=dapi&s=post&q=index&json=1&tags=' + tag, (resp) => {
|
||||||
|
|
15
src/helps/default.txt
Normal file
15
src/helps/default.txt
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
This is the default help message, you can access help messages by typing `/help <command help>`.
|
||||||
|
|
||||||
|
List of helps messages :
|
||||||
|
|
||||||
|
-`/help`
|
||||||
|
|
||||||
|
-`/help images`
|
||||||
|
|
||||||
|
-`/help openai`
|
||||||
|
|
||||||
|
-`/help games`
|
||||||
|
|
||||||
|
-`/help r34`
|
||||||
|
|
||||||
|
-`/help tools`
|
9
src/helps/games.txt
Normal file
9
src/helps/games.txt
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
This is the games help message :
|
||||||
|
|
||||||
|
list of games commands :
|
||||||
|
|
||||||
|
-`/rps <rock/paper/scissors>` (used to play rock paper scissors against the bot)
|
||||||
|
|
||||||
|
-`/truce` (reply to a message with that command to verify it)
|
||||||
|
|
||||||
|
-`/dadjoke` (send a dad joke)
|
5
src/helps/images.txt
Normal file
5
src/helps/images.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
This is the images help message :
|
||||||
|
|
||||||
|
list of images commands :
|
||||||
|
|
||||||
|
-`/s <query>` (send a random image of google for your query)
|
5
src/helps/openAI.txt
Normal file
5
src/helps/openAI.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
This is the opanAI help message :
|
||||||
|
|
||||||
|
list of opanAI commands :
|
||||||
|
|
||||||
|
-`/g <query>` (generate an image with DALL-E with your query)
|
9
src/helps/r34.txt
Normal file
9
src/helps/r34.txt
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
This is the rule34 help message :
|
||||||
|
|
||||||
|
list of rule34 commands :
|
||||||
|
|
||||||
|
-`/rtag <query>` (search for a tag on rule34 site)
|
||||||
|
|
||||||
|
-`/r34 <tag>` (send a random rule34 image of your tag)
|
||||||
|
|
||||||
|
ps: only use these commands in private messages
|
9
src/helps/tools.txt
Normal file
9
src/helps/tools.txt
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
This is the tools help message :
|
||||||
|
|
||||||
|
list of tools commands :
|
||||||
|
|
||||||
|
-`/suggest <suggestion>` (suggest a new feature for the bot)
|
||||||
|
|
||||||
|
-`/github` (send the GitHub repository link)
|
||||||
|
|
||||||
|
-`/chatinfo` (send the current chat ID)
|
Loading…
Add table
Add a link
Reference in a new issue