Compare commits
No commits in common. "main" and "v3.5.0-prod" have entirely different histories.
main
...
v3.5.0-pro
@ -34,13 +34,13 @@ jobs:
|
||||
- name: Build the Docker image
|
||||
run: |
|
||||
cd /var/lib/act_runner/nodbot
|
||||
docker build --target dev . --file Dockerfile --tag v0idf1sh/nodbot:dev
|
||||
docker build . --file Dockerfile --tag v0idf1sh/nodbot-dev
|
||||
- name: Log into Docker Hub
|
||||
run: docker login -u $DHUB_UNAME -p $DHUB_PWORD
|
||||
- name: Push image to Docker Hub
|
||||
run: |
|
||||
cd /var/lib/act_runner/nodbot
|
||||
docker push v0idf1sh/nodbot:dev
|
||||
docker push v0idf1sh/nodbot-dev
|
||||
- name: Restart the container
|
||||
run: |
|
||||
cd /srv/docker/nodbot-dev
|
||||
|
||||
@ -33,13 +33,13 @@ jobs:
|
||||
- name: Build the Docker image
|
||||
run: |
|
||||
cd /var/lib/act_runner/nodbot
|
||||
docker build --target prod . --file Dockerfile --tag v0idf1sh/nodbot:prod
|
||||
docker build . --file Dockerfile --tag v0idf1sh/nodbot
|
||||
- name: Log into Docker Hub
|
||||
run: docker login -u $DHUB_UNAME -p $DHUB_PWORD
|
||||
- name: Push image to Docker Hub
|
||||
run: |
|
||||
cd /var/lib/act_runner/nodbot
|
||||
docker push v0idf1sh/nodbot:prod
|
||||
docker push v0idf1sh/nodbot
|
||||
- name: Restart the container
|
||||
run: |
|
||||
cd /srv/docker/nodbot
|
||||
|
||||
@ -1,11 +1,3 @@
|
||||
## v3.6.x
|
||||
#### v3.6.1 (#32) Improving Requests
|
||||
* Start logging message URLs and timestamps when requests are submitted.
|
||||
* Plan to improve request submission process to interactive slash-command.
|
||||
|
||||
#### v3.6.0 (#31) Fixing GIF APIs
|
||||
* Switch from Tenor to Giphy for GIFs
|
||||
|
||||
## v3.5.x
|
||||
#### v3.5.0 (#30) The April Fools Update
|
||||
* Add April Fools stuff
|
||||
|
||||
13
Dockerfile
13
Dockerfile
@ -1,15 +1,4 @@
|
||||
# Dev Build
|
||||
FROM node:18 AS dev
|
||||
RUN mkdir -p /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY package.json ./
|
||||
RUN npm install
|
||||
COPY . .
|
||||
# Invoke the bot without redirecting STDOUT and STDERR so that docker logs can be used.
|
||||
CMD ["/bin/sh", "-c", "node main.js"]
|
||||
|
||||
FROM node:18 AS prod
|
||||
FROM node:18
|
||||
RUN mkdir -p /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# About Nodbot
|
||||
Nodbot is a content saving and serving Discord bot. Nodbot is able to search GIPHY for GIFs, save custom copypastas, and look up marijuana strain information. Nodbot is in semi-active development by voidf1sh. It's buggy as hell and very shoddily built. Don't use it.
|
||||
Nodbot is a content saving and serving Discord bot. Nodbot is able to search Tenor for GIFs, save custom copypastas, and look up marijuana strain information. Nodbot is in semi-active development by voidf1sh. It's buggy as hell and very shoddily built. Don't use it.
|
||||
|
||||
# Nodbot Help
|
||||
|
||||
@ -16,7 +16,7 @@ Use the `/help` command to see the bot's help message.
|
||||
1. Create an application at the [Discord Developer Portal](https://discord.com/developers/applications)
|
||||
2. Convert the application into a Bot
|
||||
3. Note down the token provided and keep this safe. You cannot view this token again, only regenerate a new one.
|
||||
4. Create a GIPHY account and obtain an API key.
|
||||
4. Create a Tenor account and obtain an API key.
|
||||
5. Install and configure MySQL or MariaDB with a user for the bot and a datbase
|
||||
* Create the table structure as outlined below (* Nodbot will soon create its own table structure)
|
||||
6. Configure your environment variables as outlined below.
|
||||
@ -84,7 +84,7 @@ dbPort=<mySQL port (3306)>
|
||||
dbUser=<mySQL username>
|
||||
dbPass=<mySQL user password>
|
||||
dbName=<mySQL table name>
|
||||
giphyAPIKey=<GIPHY API Key>
|
||||
tenorAPIKey=<Tenor API Key>
|
||||
ownerId=<your Discord user ID>
|
||||
statusChannelId=<Discord channel ID of channel used for status messages>
|
||||
clientId=<Discord user ID of your bot>
|
||||
|
||||
@ -2,6 +2,10 @@ const fn = require('../functions');
|
||||
const axios = require('axios');
|
||||
const dotenv = require('dotenv').config();
|
||||
|
||||
// TODO: Tenor has changed API versions, switch from TenorJS (unmaintained) to axios for
|
||||
// general API usage. See: https://github.com/Jinzulen/TenorJS/issues/12
|
||||
// see also: https://developers.google.com/tenor/guides/migrate-from-v1
|
||||
|
||||
module.exports = {
|
||||
name: 'gif',
|
||||
description: 'Send a GIF',
|
||||
@ -11,12 +15,11 @@ module.exports = {
|
||||
// if (message.deletable) message.delete();
|
||||
const client = message.client;
|
||||
if (!client.gifs.has(commandData.args.toLowerCase())) {
|
||||
// TODO: Implement proper logging
|
||||
if (process.env.isDev) console.log('https://api.giphy.com/v2/search?' + `&q=${commandData.args}` + `&key=${process.env.giphyAPIKey}` + '&limit=1&contentfilter=off');
|
||||
if (process.env.isDev) console.log('https://tenor.googleapis.com/v2/search?' + `&q=${commandData.args}` + `&key=${process.env.tenorAPIKey}` + '&limit=1&contentfilter=off');
|
||||
const q = await axios.get(
|
||||
'https://api.giphy.com/v2/search?' +
|
||||
'https://tenor.googleapis.com/v2/search?' +
|
||||
`&q=${commandData.args}` +
|
||||
`&key=${process.env.giphyAPIKey}` +
|
||||
`&key=${process.env.tenorAPIKey}` +
|
||||
'&limit=1' +
|
||||
`&contentfilter=off`
|
||||
).then(async (res) => {
|
||||
@ -42,6 +45,17 @@ module.exports = {
|
||||
await message.reply(commandData.embed_url);
|
||||
}
|
||||
}).catch(err => console.error(err));
|
||||
// tenor.Search.Query(commandData.args, "1").then(res => {
|
||||
// if (res[0] == undefined) {
|
||||
// message.reply('Sorry I was unable to find a GIF of ' + commandData.args);
|
||||
// return;
|
||||
// };
|
||||
// commandData.embed_url = res[0].media[0].gif.url;
|
||||
// // message.reply(fn.embeds.gif(commandData));
|
||||
// // message.channel.send(`> ${commandData.author} - ${commandData.args}.gif`);
|
||||
// // message.channel.send(commandData.embed_url);
|
||||
// message.reply(commandData.embed_url);
|
||||
// }).catch(err => console.error(err));
|
||||
} else {
|
||||
// message.reply(commandData.args + ' requested by ' + message.author.username + '\n' + client.gifs.get(commandData.args).embed_url);
|
||||
const gifData = client.gifs.get(commandData.args.toLowerCase());
|
||||
|
||||
@ -5,25 +5,13 @@ module.exports = {
|
||||
description: 'Submit a request to the bot developer.',
|
||||
usage: '<request or feedback>.request',
|
||||
execute(message, commandData) {
|
||||
// Get the request information from the command data that was passed in
|
||||
const requestText = commandData.args;
|
||||
const messageUrl = message.url;
|
||||
const requester = message.author.username;
|
||||
|
||||
try {
|
||||
fn.upload.request(requester, requestText, messageUrl, message.client);
|
||||
// Set the content to sent a text embed notifying the user of success
|
||||
commandData.content = `Your request has been submitted!\nRequest: ${requestText}`;
|
||||
const replyEmbed = fn.embeds.text(commandData);
|
||||
message.reply({ embeds: [ replyEmbed ]});
|
||||
} catch(err) {
|
||||
console.error(err);
|
||||
commandData.content = "An error occurred while saving the request, please try again later.";
|
||||
const replyEmbed = fn.embeds.text(commandData);
|
||||
message.reply({ embeds: [ replyEmbed ]});
|
||||
|
||||
const errorEmbed = fn.embeds.error(`An error has occurred in command ${this.name}:\n${err}`);
|
||||
fn.sendAlert(errorEmbed, message.client);
|
||||
}
|
||||
const request = commandData.args;
|
||||
commandData.content = `Your request has been submitted!\nRequest: ${request}`;
|
||||
message.reply(fn.embeds.text(commandData));
|
||||
commandData.content = `A new request has been submitted by ${message.author.tag}:\n${commandData.args}`;
|
||||
message.client.users.fetch(process.env.ownerID).then(user => {
|
||||
user.send(fn.embeds.text(commandData));
|
||||
}).catch(error => { console.error(error); });
|
||||
fn.upload.request(commandData, message.client);
|
||||
},
|
||||
};
|
||||
36
functions.js
36
functions.js
@ -9,7 +9,6 @@ const dbPass = process.env.dbPass;
|
||||
const dbPort = process.env.dbPort;
|
||||
const isDev = process.env.isDev;
|
||||
const ownerId = process.env.ownerId;
|
||||
const statusChannelId = process.env.statusChannelId;
|
||||
|
||||
// filesystem
|
||||
const fs = require('fs');
|
||||
@ -27,7 +26,6 @@ const axios = require('axios');
|
||||
// Various imports from other files
|
||||
const config = require('./config.json');
|
||||
const strings = require('./strings.json');
|
||||
const appVersion = require('./package.json').version;
|
||||
const slashCommandFiles = fs.readdirSync('./slash-commands/').filter(file => file.endsWith('.js'));
|
||||
const dotCommandFiles = fs.readdirSync('./dot-commands/').filter(file => file.endsWith('.js'));
|
||||
const customEmbeds = require('./CustomModules/Embeds.js');
|
||||
@ -184,8 +182,7 @@ const functions = {
|
||||
const helpEmbed = new Discord.MessageEmbed()
|
||||
.setColor('BLUE')
|
||||
.setAuthor({name: 'Help Page'})
|
||||
.setThumbnail(strings.urls.avatar)
|
||||
.setFooter(`v${appVersion}`);
|
||||
.setThumbnail(strings.urls.avatar);
|
||||
|
||||
// Construct the Slash Commands help
|
||||
|
||||
@ -303,13 +300,11 @@ const functions = {
|
||||
return { embeds: [jointsEmbed], components: [jointsPageAR], ephemeral: true };
|
||||
},
|
||||
text(commandData) {
|
||||
const textEmbed = new Discord.MessageEmbed()
|
||||
.setAuthor({ name: commandData.command })
|
||||
return { embeds: [new Discord.MessageEmbed()
|
||||
.setAuthor({name: commandData.command})
|
||||
.setDescription(commandData.content)
|
||||
.setTimestamp()
|
||||
.setFooter({text: commandData.author});
|
||||
|
||||
return textEmbed;
|
||||
.setFooter({text: commandData.author})]};
|
||||
},
|
||||
requests(commandData, indexedRequests) {
|
||||
const requestsEmbed = new Discord.MessageEmbed()
|
||||
@ -461,14 +456,6 @@ const functions = {
|
||||
.setDescription('* Data Collection – NodBot does collect personal data, including but not limited to: location, IP address, MAC address, physical address, mother\'s maiden name, social security number, credit card numbers, phone fingerprints, physical fingerprints, penis length and girth, first pet\'s name, city where you met your spouse, and city where your parents met.\n* Payment Info – All payments are processed through a sketchy-looking PayPal link. NodBot and voidf1sh take no responsibility if your bank, CPA, lawyer, or local PD calls you afterward.\n* Chat Logs – NodBot may or may not remember every dumbass thing you’ve ever typed. Just assume it does.\n* Third-Party Sharing – Your usage data may be shared with savage\'s mom\n* Right to Be Forgotten – You can request NodBot forget your existence, but that requires a one-time processing fee of $50.');
|
||||
|
||||
return { content: announcement, embeds: [ embed1, embed2 ] };
|
||||
},
|
||||
error(errorText) {
|
||||
const errorEmbed = new Discord.MessageEmbed()
|
||||
.setAuthor({ name: "Error!" })
|
||||
.setDescription(errorText)
|
||||
.setFooter({ text: appVersion });
|
||||
|
||||
return errorEmbed;
|
||||
}
|
||||
},
|
||||
collect: {
|
||||
@ -478,8 +465,8 @@ const functions = {
|
||||
},
|
||||
},
|
||||
upload: {
|
||||
request(requester, requestText, messageUrl, client) {
|
||||
const query = `INSERT INTO requests (author, request, status, url) VALUES (${db.escape(requester)},${db.escape(requestText)},'Active',${db.escape(messageUrl)})`;
|
||||
request(commandData, client) {
|
||||
const query = `INSERT INTO requests (author, request, status) VALUES (${db.escape(commandData.author)},${db.escape(commandData.args)},'Active')`;
|
||||
db.query(query, (err, rows, fields) => {
|
||||
if (err) throw err;
|
||||
functions.download.requests(client);
|
||||
@ -920,17 +907,6 @@ const functions = {
|
||||
}
|
||||
const errorId = digits.join("");
|
||||
return errorId;
|
||||
},
|
||||
async sendAlert(embed, client) {
|
||||
const statusChannel = await client.channels.fetch(statusChannelId)
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
await statusChannel.send({ embeds: [ embed ] })
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
15
main.js
15
main.js
@ -6,9 +6,6 @@ dotenv.config();
|
||||
const token = process.env.TOKEN;
|
||||
const statusChannelId = process.env.statusChannelId;
|
||||
|
||||
// Dump the env vars to log in dev environment:
|
||||
if (process.env.isDev === "true") console.log(JSON.stringify(process.env));
|
||||
|
||||
// Discord.JS
|
||||
const { Client, Intents } = require('discord.js');
|
||||
const client = new Client({
|
||||
@ -35,6 +32,7 @@ const ButtonHandlers = require('./CustomModules/ButtonHandlers.js');
|
||||
const InteractionStorage = require('./CustomModules/InteractionStorage.js');
|
||||
const isDev = process.env.isDev;
|
||||
let statusChannel;
|
||||
const announcementChannelId = '893183933645197312';
|
||||
|
||||
client.once('ready', async () => {
|
||||
fn.collections.interactionStorage(client);
|
||||
@ -55,6 +53,9 @@ client.once('ready', async () => {
|
||||
// console.log(JSON.stringify(icaoArray));
|
||||
statusChannel = await client.channels.fetch(statusChannelId).catch(e => console.error(e));
|
||||
await statusChannel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`).catch(e => console.error(e));
|
||||
|
||||
const announcementChannel = await client.channels.fetch(announcementChannelId).catch(e => console.error(e));
|
||||
await announcementChannel.send(fn.embeds.membershipAnnouncement()).catch(e => console.error(e));
|
||||
// Check for banned servers
|
||||
fn.checkBannedServers(client, statusChannel);
|
||||
});
|
||||
@ -72,7 +73,11 @@ client.on('interactionCreate', async interaction => {
|
||||
}
|
||||
|
||||
if (client.slashCommands.has(commandName)) {
|
||||
if (fn.checkMembership(client, interaction.user.id)) {
|
||||
client.slashCommands.get(commandName).execute(interaction);
|
||||
} else {
|
||||
interaction.reply(fn.embeds.noMembership());
|
||||
}
|
||||
} else {
|
||||
interaction.reply('Sorry, I don\'t have access to that command.');
|
||||
console.error('Slash command attempted to run but not found: ' + commandName);
|
||||
@ -142,7 +147,11 @@ client.on('messageCreate', message => {
|
||||
|
||||
if (commandData.isValid && commandData.isCommand) {
|
||||
try {
|
||||
if (fn.checkMembership(client, message.member.user.id)) {
|
||||
client.dotCommands.get(commandData.command).execute(message, commandData);
|
||||
} else {
|
||||
message.reply(fn.embeds.noMembership());
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nodbot",
|
||||
"version": "3.6.1",
|
||||
"version": "3.5.0",
|
||||
"description": "Nods and Nod Accessories",
|
||||
"main": "main.js",
|
||||
"dependencies": {
|
||||
@ -12,7 +12,8 @@
|
||||
"dotenv": "^10.0.0",
|
||||
"fuzzy-search": "^3.2.1",
|
||||
"mysql": "^2.18.1",
|
||||
"openai": "^4.12.0"
|
||||
"openai": "^4.12.0",
|
||||
"tenorjs": "^1.0.10"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18.x"
|
||||
|
||||
@ -1,3 +1,11 @@
|
||||
const tenor = require('tenorjs').client({
|
||||
'Key': process.env.tenorAPIKey, // https://tenor.com/developer/keyregistration
|
||||
'Filter': 'off', // "off", "low", "medium", "high", not case sensitive
|
||||
'Locale': 'en_US',
|
||||
'MediaFilter': 'minimal',
|
||||
'DateFormat': 'D/MM/YYYY - H:mm:ss A',
|
||||
});
|
||||
|
||||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
const { MessageActionRow, MessageButton } = require('discord.js');
|
||||
const { GifData, PastaData } = require('../CustomModules/NodBot');
|
||||
|
||||
@ -1,3 +1,11 @@
|
||||
const tenor = require('tenorjs').client({
|
||||
'Key': process.env.tenorAPIKey, // https://tenor.com/developer/keyregistration
|
||||
'Filter': 'off', // "off", "low", "medium", "high", not case sensitive
|
||||
'Locale': 'en_US',
|
||||
'MediaFilter': 'minimal',
|
||||
'DateFormat': 'D/MM/YYYY - H:mm:ss A',
|
||||
});
|
||||
|
||||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
const { Collection } = require('discord.js');
|
||||
const fn = require('../functions.js');
|
||||
@ -16,7 +24,7 @@ module.exports = {
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName('gifsearch')
|
||||
.setDescription('Search GIPHY for a GIF.')
|
||||
.setDescription('Search Tenor for a GIF.')
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('query')
|
||||
@ -146,34 +154,34 @@ module.exports = {
|
||||
iStorage.gifName = gifName;
|
||||
iStorage.query = query;
|
||||
|
||||
interaction.editReply("Fuck off this is broken, come back later.");
|
||||
|
||||
|
||||
// Search Tenor for the GIF
|
||||
// tenor.Search.Query(query, '20').then(res => {
|
||||
tenor.Search.Query(query, '20').then(res => {
|
||||
|
||||
// strings.temp.gifs = [];
|
||||
// strings.temp.gifIndex = 0;
|
||||
// strings.temp.gifLimit = res.length - 1;
|
||||
// strings.temp.gifUserId = interaction.user.id;
|
||||
strings.temp.gifs = [];
|
||||
strings.temp.gifIndex = 0;
|
||||
strings.temp.gifLimit = res.length - 1;
|
||||
strings.temp.gifUserId = interaction.user.id;
|
||||
|
||||
// if (res[0] == undefined) {
|
||||
// interaction.editReply('Sorry I was unable to find a GIF of ' + query);
|
||||
// return;
|
||||
// }
|
||||
// for (const row of res) {
|
||||
// iStorage.gifsCollection.set(row.id, row);
|
||||
// }
|
||||
if (res[0] == undefined) {
|
||||
interaction.editReply('Sorry I was unable to find a GIF of ' + query);
|
||||
return;
|
||||
}
|
||||
for (const row of res) {
|
||||
iStorage.gifsCollection.set(row.id, row);
|
||||
}
|
||||
|
||||
// // Generate the initial action row
|
||||
// const actionRow = customEmbeds.actionRows.gifSearchAR('first');
|
||||
// // Get the index built
|
||||
// const gifPage = Indexer(iStorage.gifsCollection, 0, 1);
|
||||
// gifPage.query = query;
|
||||
// gifPage.gifName = gifName;
|
||||
// // Generate the embed
|
||||
// const gifEmbed = Embeds.core.gifSearch({ author: interaction.user.username }, gifPage);
|
||||
// interaction.editReply({ embeds: [gifEmbed], components: [actionRow], ephemeral: true });
|
||||
// });
|
||||
// Generate the initial action row
|
||||
const actionRow = customEmbeds.actionRows.gifSearchAR('first');
|
||||
// Get the index built
|
||||
const gifPage = Indexer(iStorage.gifsCollection, 0, 1);
|
||||
gifPage.query = query;
|
||||
gifPage.gifName = gifName;
|
||||
// Generate the embed
|
||||
const gifEmbed = Embeds.core.gifSearch({ author: interaction.user.username }, gifPage);
|
||||
interaction.editReply({ embeds: [gifEmbed], components: [actionRow], ephemeral: true });
|
||||
});
|
||||
break;
|
||||
// GIF URL
|
||||
case "gifurl":
|
||||
|
||||
@ -1,3 +1,11 @@
|
||||
const tenor = require('tenorjs').client({
|
||||
'Key': process.env.tenorAPIKey, // https://tenor.com/developer/keyregistration
|
||||
'Filter': 'off', // "off", "low", "medium", "high", not case sensitive
|
||||
'Locale': 'en_US',
|
||||
'MediaFilter': 'minimal',
|
||||
'DateFormat': 'D/MM/YYYY - H:mm:ss A',
|
||||
});
|
||||
|
||||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
const { Collection } = require('discord.js');
|
||||
const fn = require('../functions.js');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user