Compare commits
29 Commits
ab929489b0
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33680209ba | ||
|
|
f70ea4229a | ||
|
|
acadc9faee | ||
|
|
f725ec88f9 | ||
|
|
8d34b93527 | ||
|
|
918cfe06e4 | ||
|
|
e2f276e65b | ||
| 52353ec1fb | |||
|
|
750877db1a | ||
|
|
a18337d0f8 | ||
|
|
6f45a60030 | ||
|
|
1fb4728b0a | ||
|
|
ebf48c7618 | ||
|
|
11b3504f28 | ||
|
|
14171a9c13 | ||
|
|
47a03898cc | ||
|
|
2551498d2e | ||
|
|
277f7d176a | ||
|
|
066404dd10 | ||
|
|
8f2891f5d8 | ||
|
|
9f2ed48caf | ||
|
|
3f42d60efc | ||
|
|
cf9f48dfa7 | ||
|
|
bde7dbce45 | ||
|
|
a8e96ab5dc | ||
|
|
628fd80710 | ||
|
|
edb7ec41b1 | ||
|
|
0be5b059da | ||
|
|
46989942d8 |
56
.gitea/workflows/DRBv3_docs.yaml
Normal file
56
.gitea/workflows/DRBv3_docs.yaml
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
name: Update Wiki from JSDoc
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
# schedule:
|
||||||
|
# - cron: '0 0 * * 1' # Every Monday at midnight (UTC)
|
||||||
|
|
||||||
|
|
||||||
|
env:
|
||||||
|
NODE_ENV: development
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-wiki:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout the code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install
|
||||||
|
|
||||||
|
- name: Generate JSDoc
|
||||||
|
run: npm run docs
|
||||||
|
|
||||||
|
- name: Checkout the wiki repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: logan/drb-server.wiki # Replace with your wiki repository
|
||||||
|
path: wiki
|
||||||
|
|
||||||
|
- name: Output Generated Documentation
|
||||||
|
run: |
|
||||||
|
cat Home.md
|
||||||
|
ls
|
||||||
|
|
||||||
|
- name: Update wiki
|
||||||
|
run: |
|
||||||
|
cp -rf Home.md wiki/Home.md
|
||||||
|
cd wiki
|
||||||
|
git config user.name "gitea-actions"
|
||||||
|
git config user.email "gitea-actions@cusano.net"
|
||||||
|
git add .
|
||||||
|
# Check if there are any changes to commit
|
||||||
|
if git diff --cached --quiet; then
|
||||||
|
echo "No changes to commit."
|
||||||
|
else
|
||||||
|
git commit -m "Update wiki from JSDoc"
|
||||||
|
git push
|
||||||
|
fi
|
||||||
@@ -5,6 +5,8 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- "*"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint-js:
|
lint-js:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name: DRB Tests
|
|||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- "*"
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|||||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -301,4 +301,7 @@ config/
|
|||||||
op25/
|
op25/
|
||||||
|
|
||||||
# Ignore any local run scripts for development
|
# Ignore any local run scripts for development
|
||||||
*.bat
|
*.bat
|
||||||
|
|
||||||
|
# Ignore the auto-generated docs folder
|
||||||
|
/docs
|
||||||
@@ -12,7 +12,7 @@ RUN npm install -g node-gyp
|
|||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
# Copy the rest of the application code to the working directory
|
# Copy the rest of the application code to the working directory
|
||||||
COPY . .
|
COPY ./src ./src
|
||||||
|
|
||||||
# Expose the port on which your Node.js application will run
|
# Expose the port on which your Node.js application will run
|
||||||
EXPOSE 3420
|
EXPOSE 3420
|
||||||
|
|||||||
@@ -14,15 +14,19 @@ const compat = new FlatCompat({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
|
// Apply ESLint recommended settings first
|
||||||
...compat.extends().map((config) => ({
|
...compat.extends().map((config) => ({
|
||||||
...config,
|
...config,
|
||||||
|
files: ["src/**/*.mjs", "src/**/*.js", "src/**/*.cjs"],
|
||||||
|
})),
|
||||||
|
|
||||||
|
// Custom rules and plugin configuration
|
||||||
|
{
|
||||||
plugins: {
|
plugins: {
|
||||||
"unused-imports": unusedImports,
|
"unused-imports": unusedImports,
|
||||||
},
|
},
|
||||||
files: ["**/*.mjs", "**/*.js", "**/*.cjs"],
|
|
||||||
rules: {
|
rules: {
|
||||||
...config.rules,
|
// Custom rules here
|
||||||
// ...other your custom rules
|
|
||||||
"no-console": "warn",
|
"no-console": "warn",
|
||||||
"no-unused-vars": "off", // or "@typescript-eslint/no-unused-vars": "off",
|
"no-unused-vars": "off", // or "@typescript-eslint/no-unused-vars": "off",
|
||||||
"unused-imports/no-unused-imports": "error",
|
"unused-imports/no-unused-imports": "error",
|
||||||
@@ -35,8 +39,9 @@ export default [
|
|||||||
argsIgnorePattern: "^_",
|
argsIgnorePattern: "^_",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"prettier/prettier": "warn", // Integrate prettier
|
||||||
},
|
},
|
||||||
})),
|
},
|
||||||
prettierConfig, // Turns off all ESLint rules that have the potential to interfere with Prettier rules.
|
prettierConfig, // Turns off all ESLint rules that have the potential to interfere with Prettier rules.
|
||||||
eslintPluginPrettierRecommended,
|
eslintPluginPrettierRecommended,
|
||||||
];
|
];
|
||||||
|
|||||||
10
jsdoc.conf
Normal file
10
jsdoc.conf
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"source": {
|
||||||
|
"includePattern": ".+([mc]?js(doc|x)?)$"
|
||||||
|
},
|
||||||
|
"plugins": ["node_modules/jsdoc-babel"],
|
||||||
|
"babel": {
|
||||||
|
"presets": [ "es2015" ],
|
||||||
|
"plugins": [ "transform-async-to-generator" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
4
makefile
4
makefile
@@ -21,10 +21,6 @@ run:
|
|||||||
-e MONGO_URL=${MONGO_URL} \
|
-e MONGO_URL=${MONGO_URL} \
|
||||||
-e DISCORD_TOKEN=${DISCORD_TOKEN} \
|
-e DISCORD_TOKEN=${DISCORD_TOKEN} \
|
||||||
-e RSS_REFRESH_INTERVAL=${RSS_REFRESH_INTERVAL} \
|
-e RSS_REFRESH_INTERVAL=${RSS_REFRESH_INTERVAL} \
|
||||||
-e WELCOME_CHANNEL_ID=${WELCOME_CHANNEL_ID} \
|
|
||||||
-e IGNORED_CHANNEL_IDS=${IGNORED_CHANNEL_IDS} \
|
|
||||||
-e LINKCOP_RESTRICTED_CHANNEL_IDS=${LINKCOP_RESTRICTED_CHANNEL_IDS} \
|
|
||||||
-e DRB_SERVER_INITIAL_PROMPT=${DRB_SERVER_INITIAL_PROMPT} \
|
|
||||||
-e OPENAI_API_KEY=${OPENAI_API_KEY} \
|
-e OPENAI_API_KEY=${OPENAI_API_KEY} \
|
||||||
-e LOG_LOCATION="./logs/server.log" \
|
-e LOG_LOCATION="./logs/server.log" \
|
||||||
-p ${SERVER_PORT}:${SERVER_PORT} \
|
-p ${SERVER_PORT}:${SERVER_PORT} \
|
||||||
|
|||||||
2329
package-lock.json
generated
2329
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -2,22 +2,27 @@
|
|||||||
"name": "drb-server",
|
"name": "drb-server",
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "server.js",
|
"main": "src/server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"docs": "jsdoc2md -c jsdoc.conf src/*js > Home.md",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"lint:fix": "eslint --fix .",
|
"lint:fix": "eslint --fix .",
|
||||||
"test": "mocha --timeout 5000",
|
"test": "mocha --timeout 5000",
|
||||||
"start": "node server.js"
|
"start": "node src/server.js"
|
||||||
},
|
},
|
||||||
"author": "Logan Cusano",
|
"author": "Logan Cusano",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"babel-plugin-transform-async-to-generator": "^6.24.1",
|
||||||
|
"babel-preset-es2015": "^6.24.1",
|
||||||
"chai": "^5.1.1",
|
"chai": "^5.1.1",
|
||||||
"eslint": "^9.9.0",
|
"eslint": "^9.9.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-prettier": "^5.2.1",
|
"eslint-plugin-prettier": "^5.2.1",
|
||||||
"eslint-plugin-unused-imports": "^4.1.3",
|
"eslint-plugin-unused-imports": "^4.1.3",
|
||||||
|
"jsdoc-babel": "^0.5.0",
|
||||||
|
"jsdoc-to-markdown": "^8.0.3",
|
||||||
"mocha": "^10.4.0",
|
"mocha": "^10.4.0",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"socket.io-client": "^4.7.5"
|
"socket.io-client": "^4.7.5"
|
||||||
|
|||||||
@@ -2,10 +2,7 @@ import { DebugBuilder } from "../../modules/debugger.mjs";
|
|||||||
const log = new DebugBuilder("server", "discordBot.addons.linkCop");
|
const log = new DebugBuilder("server", "discordBot.addons.linkCop");
|
||||||
import { gptHandler } from "../modules/gptHandler.mjs";
|
import { gptHandler } from "../modules/gptHandler.mjs";
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
import {
|
import { getGuildConfig } from "../../modules/mongo-wrappers/mongoConfigWrappers.mjs";
|
||||||
getGuildConfig,
|
|
||||||
setGuildConfig,
|
|
||||||
} from "../../modules/mongo-wrappers/mongoConfigWrappers.mjs";
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
const linkRegExp = /http[s]?:\/\/\S+/g;
|
const linkRegExp = /http[s]?:\/\/\S+/g;
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import { SlashCommandBuilder } from "discord.js";
|
import { SlashCommandBuilder } from "discord.js";
|
||||||
import { DebugBuilder } from "../../modules/debugger.mjs";
|
import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||||
import { removeSource } from "../../rss-manager/sourceManager.mjs";
|
|
||||||
import {
|
import {
|
||||||
getAllFeeds,
|
getAllFeeds,
|
||||||
deleteFeedByTitle,
|
deleteFeedByTitle,
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
import { DebugBuilder } from "../modules/debugger.mjs";
|
import { DebugBuilder } from "../modules/debugger.mjs";
|
||||||
import { Client, GatewayIntentBits, Collection } from "discord.js";
|
import { Client, GatewayIntentBits, Collection } from "discord.js";
|
||||||
import {
|
import { registerActiveCommands } from "./modules/registerCommands.mjs";
|
||||||
registerActiveCommands,
|
|
||||||
unregisterAllCommands,
|
|
||||||
} from "./modules/registerCommands.mjs";
|
|
||||||
import { RSSController } from "../rss-manager/rssController.mjs";
|
import { RSSController } from "../rss-manager/rssController.mjs";
|
||||||
import { join, dirname } from "path";
|
import { join, dirname } from "path";
|
||||||
import { readdirSync } from "fs";
|
import { readdirSync } from "fs";
|
||||||
@@ -4,12 +4,7 @@ import dotenv from "dotenv";
|
|||||||
dotenv.config();
|
dotenv.config();
|
||||||
import { Events } from "discord.js";
|
import { Events } from "discord.js";
|
||||||
import { gptHandler } from "../modules/gptHandler.mjs";
|
import { gptHandler } from "../modules/gptHandler.mjs";
|
||||||
import {
|
import { getGuildConfig } from "../../modules/mongo-wrappers/mongoConfigWrappers.mjs";
|
||||||
getGuildConfig,
|
|
||||||
setGuildConfig,
|
|
||||||
getConfig,
|
|
||||||
setConfig,
|
|
||||||
} from "../../modules/mongo-wrappers/mongoConfigWrappers.mjs";
|
|
||||||
|
|
||||||
export const name = Events.GuildMemberAdd;
|
export const name = Events.GuildMemberAdd;
|
||||||
|
|
||||||
@@ -6,10 +6,7 @@ import { Events } from "discord.js";
|
|||||||
import { gptInteraction } from "../addons/gptInteraction.mjs";
|
import { gptInteraction } from "../addons/gptInteraction.mjs";
|
||||||
import { linkCop } from "../addons/linkCop.mjs";
|
import { linkCop } from "../addons/linkCop.mjs";
|
||||||
import PresenceManager from "../modules/presenceManager.mjs";
|
import PresenceManager from "../modules/presenceManager.mjs";
|
||||||
import {
|
import { getGuildConfig } from "../../modules/mongo-wrappers/mongoConfigWrappers.mjs";
|
||||||
getGuildConfig,
|
|
||||||
setGuildConfig,
|
|
||||||
} from "../../modules/mongo-wrappers/mongoConfigWrappers.mjs";
|
|
||||||
|
|
||||||
export const name = Events.MessageCreate;
|
export const name = Events.MessageCreate;
|
||||||
|
|
||||||
@@ -4,10 +4,13 @@ import {
|
|||||||
} from "../../modules/mongo-wrappers/mongoConfigWrappers.mjs";
|
} from "../../modules/mongo-wrappers/mongoConfigWrappers.mjs";
|
||||||
import { ActivityType, PresenceUpdateStatus } from "discord.js";
|
import { ActivityType, PresenceUpdateStatus } from "discord.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Control the presence or activity of the discord bot.
|
||||||
|
*/
|
||||||
class PresenceManager {
|
class PresenceManager {
|
||||||
/**
|
/**
|
||||||
* Creates an instance of PresenceManager.
|
* Creates an instance of PresenceManager.
|
||||||
* @param {import('discord.js').Client} client - The Discord client instance.
|
* @param {Client} client - The Discord client instance.
|
||||||
*/
|
*/
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
@@ -4,7 +4,6 @@ import {
|
|||||||
checkIfNodeIsConnectedToVC,
|
checkIfNodeIsConnectedToVC,
|
||||||
getNodeDiscordID,
|
getNodeDiscordID,
|
||||||
getNodeDiscordUsername,
|
getNodeDiscordUsername,
|
||||||
checkIfNodeHasOpenDiscordClient,
|
|
||||||
getNodeCurrentListeningSystem,
|
getNodeCurrentListeningSystem,
|
||||||
requestNodeJoinSystem,
|
requestNodeJoinSystem,
|
||||||
} from "../../modules/socketServerWrappers.mjs";
|
} from "../../modules/socketServerWrappers.mjs";
|
||||||
@@ -86,9 +85,8 @@ export const getAvailableNodes = async (nodeIo, guildId, system) => {
|
|||||||
openSockets.map(async (openSocket) => {
|
openSockets.map(async (openSocket) => {
|
||||||
openSocket = await nodeIo.sockets.sockets.get(openSocket);
|
openSocket = await nodeIo.sockets.sockets.get(openSocket);
|
||||||
// Check if the node has an existing open client (meaning the radio is already being listened to)
|
// Check if the node has an existing open client (meaning the radio is already being listened to)
|
||||||
const hasOpenClient = await checkIfNodeHasOpenDiscordClient(openSocket);
|
let currentSystem = await getNodeCurrentListeningSystem(openSocket);
|
||||||
if (hasOpenClient) {
|
if (currentSystem) {
|
||||||
let currentSystem = await getNodeCurrentListeningSystem(openSocket);
|
|
||||||
if (currentSystem != system.name) {
|
if (currentSystem != system.name) {
|
||||||
log.INFO(
|
log.INFO(
|
||||||
"Node is listening to a different system than requested",
|
"Node is listening to a different system than requested",
|
||||||
@@ -60,7 +60,7 @@ export const getGuildConfig = async (guildId, key) => {
|
|||||||
try {
|
try {
|
||||||
const config = await getDocumentByFields(
|
const config = await getDocumentByFields(
|
||||||
collectionName,
|
collectionName,
|
||||||
["guildId", guildId],
|
["guild", Number(guildId)],
|
||||||
["key", key],
|
["key", key],
|
||||||
);
|
);
|
||||||
log.DEBUG(
|
log.DEBUG(
|
||||||
@@ -82,7 +82,7 @@ export const setGuildConfig = async (guildId, key, value) => {
|
|||||||
const result = await upsertDocumentByFields(
|
const result = await upsertDocumentByFields(
|
||||||
collectionName,
|
collectionName,
|
||||||
value,
|
value,
|
||||||
["guildId", guildId],
|
["guild", Number(guildId)],
|
||||||
["key", key],
|
["key", key],
|
||||||
);
|
);
|
||||||
log.DEBUG(`Guild ${guildId} configuration for key "${key}" set:`, value);
|
log.DEBUG(`Guild ${guildId} configuration for key "${key}" set:`, value);
|
||||||
@@ -98,7 +98,7 @@ export const deleteGuildConfig = async (guildId, key) => {
|
|||||||
try {
|
try {
|
||||||
const result = await deleteDocumentByFields(
|
const result = await deleteDocumentByFields(
|
||||||
collectionName,
|
collectionName,
|
||||||
["guildId", guildId],
|
["guild", Number(guildId)],
|
||||||
["key", key],
|
["key", key],
|
||||||
);
|
);
|
||||||
log.DEBUG(
|
log.DEBUG(
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
import { DebugBuilder } from "./modules/debugger.mjs";
|
import { DebugBuilder } from "./modules/debugger.mjs";
|
||||||
const log = new DebugBuilder("server", "server");
|
const log = new DebugBuilder("server", "server");
|
||||||
import { nodeIo, app, server } from "./modules/socketServer.mjs";
|
import { nodeIo, server } from "./modules/socketServer.mjs";
|
||||||
import { loadAddons } from "./modules/addonManager.mjs";
|
import { loadAddons } from "./modules/addonManager.mjs";
|
||||||
import {
|
import { serverClient } from "./discordBot/discordBot.mjs";
|
||||||
serverClient,
|
|
||||||
addEnabledEventListeners,
|
|
||||||
} from "./discordBot/discordBot.mjs";
|
|
||||||
|
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
@@ -4,11 +4,11 @@ import ioClient from "socket.io-client";
|
|||||||
import {
|
import {
|
||||||
deleteNodeByNuid,
|
deleteNodeByNuid,
|
||||||
getNodeByNuid,
|
getNodeByNuid,
|
||||||
} from "../modules/mongo-wrappers/mongoNodesWrappers.mjs";
|
} from "../src/modules/mongo-wrappers/mongoNodesWrappers.mjs";
|
||||||
import {
|
import {
|
||||||
deleteSystemByName,
|
deleteSystemByName,
|
||||||
getSystemByName,
|
getSystemByName,
|
||||||
} from "../modules/mongo-wrappers/mongoSystemsWrappers.mjs";
|
} from "../src/modules/mongo-wrappers/mongoSystemsWrappers.mjs";
|
||||||
import {
|
import {
|
||||||
nodeDisconnectWrapper,
|
nodeDisconnectWrapper,
|
||||||
checkIfNodeHasOpenDiscordClient,
|
checkIfNodeHasOpenDiscordClient,
|
||||||
@@ -19,8 +19,8 @@ import {
|
|||||||
requestBotLeaveServer,
|
requestBotLeaveServer,
|
||||||
requestNodeJoinSystem,
|
requestNodeJoinSystem,
|
||||||
requestNodeUpdate,
|
requestNodeUpdate,
|
||||||
} from "../modules/socketServerWrappers.mjs";
|
} from "../src/modules/socketServerWrappers.mjs";
|
||||||
import { nodeIo } from "../modules/socketServer.mjs";
|
import { nodeIo } from "../src/modules/socketServer.mjs";
|
||||||
|
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|||||||
Reference in New Issue
Block a user