Implement Dynamic Presence #19
## Added Dynamic Presence to Functions - Added default to startup - Added to RSS manager - Added to interaction create event - Added to message create function ## Related Work #15 ### LinkCop - Updated with new regex string and logic approved and restricted channels - Implemented new config storage ### Guild Member Add (event) - Implemented new config storage for welcome channel ### Message Create (event) - Implemented new config storage for ignored channel IDs - Improved the logic for gpt interactions to reset presence ### Mongo Config Wrappers - Updated logic in order to handle different data types the same way - Updated set functions to wrap the value in the key - Updated get functions to return the keyyed value ie `config[key]`
This commit is contained in:
@@ -2,25 +2,30 @@ import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("server", "discordBot.addons.linkCop");
|
||||
import { gptHandler } from "../modules/gptHandler.mjs";
|
||||
import dotenv from "dotenv";
|
||||
import { getGuildConfig, setGuildConfig } from "../../modules/mongo-wrappers/mongoConfigWrappers.mjs";
|
||||
dotenv.config();
|
||||
|
||||
const approvedLinksChannel = "767303243285790721";
|
||||
const restrictedChannelIds =
|
||||
process.env.LINKCOP_RESTRICTED_CHANNEL_IDS.split(",");
|
||||
|
||||
const linkRegExp =
|
||||
/(?:http[s]?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/g;
|
||||
const linkRegExp = /http[s]?:\/\/\S+/g;
|
||||
|
||||
export const linkCop = async (nodeIo, message) => {
|
||||
if (
|
||||
message.channel.id == approvedLinksChannel ||
|
||||
!restrictedChannelIds.includes(message.channel.id)
|
||||
)
|
||||
return false;
|
||||
// Set the channel IDs based on the guild the message was sent in
|
||||
const approvedLinksChannel = await getGuildConfig(message.guild.id, "approvedLinksChannel") || "767303243285790721";
|
||||
const restrictedChannelIds = await getGuildConfig(message.guild.id, "restrictedChannelIds");
|
||||
|
||||
// Check if the message was sent in an restricted channel
|
||||
if (
|
||||
message.channel.id == approvedLinksChannel || !Array.isArray(restrictedChannelIds) ||
|
||||
(Array.isArray(restrictedChannelIds) || !restrictedChannelIds.includes(message.channel.id))
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if there are URLs in the sent message
|
||||
const urls = [...message.content.matchAll(linkRegExp)];
|
||||
log.DEBUG("Parsed URLs from message:", urls);
|
||||
|
||||
const urls = String(message.content).matchAll(linkRegExp);
|
||||
if (!urls || urls.length === 0) return false;
|
||||
log.DEBUG("Found URLs: ", urls);
|
||||
log.INFO("Found URLs: ", urls);
|
||||
|
||||
let conversation = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user