Merge pull request 'v3.4.3-dev' (#29) from v3.4.3-dev into main

Reviewed-on: #29
This commit is contained in:
Skylar Grant 2025-02-09 22:36:11 +00:00
commit e389d5caae
8 changed files with 118 additions and 22 deletions

View File

@ -1,10 +1,16 @@
name: NodBot PE Dockerization
######################################################
# Creates a new Docker image of nodbot-dev, pushes #
# it to DockerHub, and restarts the container. #
######################################################
# Run when a new tag for dev is pushed
on:
push:
tags:
- 'v*-dev*'
# Pull DockerHub credentials from secrets
env:
DHUB_UNAME: ${{ secrets.DHUB_UNAME }}
DHUB_PWORD: ${{ secrets.DHUB_PWORD }}
@ -13,21 +19,17 @@ jobs:
build:
runs-on: self-hosted
steps:
- name: Clean up old environment
run: |
rm -rf /var/lib/act_runner/nodbot
rm -rf /var/lib/act_runner/nodbot-dev
- name: Pull latest from Git
run: |
echo "Ref: ${{ gitea.ref_name }}"
echo "Branch: tags/${{ gitea.ref_name }}"
pwd
whoami
mkdir -p /var/lib/act_runner/
cd /var/lib/act_runner/
if [ ! -d "nodbot" ]; then
git clone https://git.vfsh.dev/voidf1sh/nodbot
cd nodbot
else
cd nodbot
git checkout main
git pull
fi
cd /var/lib/act_runner
git clone https://git.vfsh.dev/voidf1sh/nodbot
cd nodbot
git checkout tags/${{ gitea.ref_name }}
- name: Build the Docker image
run: |

View File

@ -1,6 +1,10 @@
## v3.4.x
#### v3.4.3 (#29)
* Fix `.gif` replies to redirect to the original replyee (#26)
#### v3.4.2 (#28)
* Added `.drink` and aliases
* Changed `.joint` responses to be standalone instead of replies
#### v3.4.1 (#27)
* Adding command to change nicknames
@ -32,4 +36,4 @@ v3.0.4 - Add ability to use multiple aliases
v3.0.5 - Add ability to save strains
v3.0.6 - Move `.strain` to `/strain` and add Autocomplete
v3.0.7 - Add `.spongebob` replies
v3.0.8 - Add ability to open requests by pages
v3.0.8 - Add ability to open requests by pages

38
_list-guilds.js Normal file
View File

@ -0,0 +1,38 @@
/*
* Quick and dirty script to list out what guilds the bot is in and optionally leave some.
*/
const guildsToLeave = ['1224396616555823124'];
const dotenv = require('dotenv').config();
const token = process.env.TOKEN;
const Discord = require('discord.js');
const client = new Discord.Client({
intents: [
'GUILDS'
]
});
client.on('ready', async () => {
const guildChecks = [];
console.log(`Logged in as ${client.user.tag}`);
console.log('Guilds:');
client.guilds.cache.forEach((guild) => {
const p = new Promise((resolve, reject) => {
console.log(` - ${guild.name} (${guild.id})`);
if (guildsToLeave.includes(guild.id)) {
console.log(` Leaving ${guild.name}`);
guild.leave().then(resolve).catch(reject);
} else {
resolve();
}
});
guildChecks.push(p);
});
await Promise.all(guildChecks);
console.log('All guilds checked.');
client.destroy();
});
client.login(token);

View File

@ -3,5 +3,6 @@
"validCommands": [],
"roaches": [],
"icaoIds": [],
"datisICAOs": []
"datisICAOs": [],
"bannedServers": ["1224396616555823124"]
}

View File

@ -22,14 +22,28 @@ module.exports = {
`&key=${process.env.tenorAPIKey}` +
'&limit=1' +
`&contentfilter=off`
).then(res => {
).then(async (res) => {
if (process.env.isDev) console.log(res.data.results);
if (res.data.results[0] == undefined) {
message.reply('Sorry I was unable to find a GIF of ' + commandData.args);
return;
};
commandData.embed_url = res.data.results[0].url;
message.reply(commandData.embed_url);
// Handle when the invoking message is a reply to someone else
if (message.reference) {
// Fetch the referenced message from the channels' MessageManager
await message.channel.messages.fetch(message.reference.messageId).then(async (refMsg) => {
// Send the reply to the referenced message
await refMsg.reply(commandData.embed_url);
}).catch(async (e) => {
// Failed fetching the message from the channel, fallback to regular send
console.error(e);
await message.reply(commandData.embed_url);
});
} else {
await message.reply(commandData.embed_url);
}
}).catch(err => console.error(err));
// tenor.Search.Query(commandData.args, "1").then(res => {
// if (res[0] == undefined) {
@ -51,4 +65,4 @@ module.exports = {
message.reply(gifData.url);
}
}
}
}

View File

@ -671,6 +671,29 @@ const functions = {
});
});
},
checkBannedServers(client, statusChannel) {
if ( !config.bannedServers || !statusChannel ) return;
const guildChecks = [];
console.log('Guild Check:');
client.guilds.cache.forEach((guild) => {
const p = new Promise((resolve, reject) => {
console.log(` - ${guild.name} (${guild.id})`);
if (config.bannedServers.includes(guild.id)) {
console.log(` Leaving banned server: ${guild.name}`);
statusChannel.send(`<@${process.env.ownerId}> Leaving banned server: ${guild.name}`);
guild.leave().then(resolve).catch(reject);
} else {
resolve();
}
});
guildChecks.push(p);
});
Promise.all(guildChecks).then(() => {
console.log('All guilds checked.');
}).catch((err) => {
console.error(err);
});
},
autoresponses: { // Specific responses for certain keywords in sent messages
checkForAll(messageContent) {
let responses = [];

20
main.js
View File

@ -31,6 +31,7 @@ const { GifData, CommandData } = require('./CustomModules/NodBot.js');
const ButtonHandlers = require('./CustomModules/ButtonHandlers.js');
const InteractionStorage = require('./CustomModules/InteractionStorage.js');
const isDev = process.env.isDev;
let statusChannel;
client.once('ready', async () => {
fn.collections.interactionStorage(client);
@ -48,9 +49,10 @@ client.once('ready', async () => {
await fn.avWx.metar.getAllICAOs();
await fn.avWx.datis.getAllICAOs();
// console.log(JSON.stringify(icaoArray));
client.channels.fetch(statusChannelId).then(channel => {
channel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`);
});
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));
// Check for banned servers
fn.checkBannedServers(client, statusChannel);
});
// slash-commands
@ -146,4 +148,16 @@ client.on('messageCreate', message => {
return;
});
// Guild Joins and Leaves:
client.on('guildCreate', guild => {
statusChannel.send(`I've been added to a new guild: ${guild.name} (${guild.id})`)
.catch(e => console.error(e));
fn.checkBannedServers(client, statusChannel);
});
client.on('guildDelete', guild => {
statusChannel.send(`I've been removed from a guild: ${guild.name} (${guild.id})`)
.catch(e => console.error(e));
});
client.login(token);

View File

@ -1,6 +1,6 @@
{
"name": "nodbot",
"version": "3.4.2",
"version": "3.4.3",
"description": "Nods and Nod Accessories",
"main": "main.js",
"dependencies": {