Compare commits

25 Commits

Author SHA1 Message Date
Logan Cusano
dfb2765f39 Add a new key for feeds to set active status 2024-09-21 11:36:02 -04:00
Logan Cusano
33680209ba Added missing packages to dev
Some checks failed
release-tag / release-image (push) Has been cancelled
Update Wiki from JSDoc / update-wiki (push) Failing after 12s
Lint JavaScript/Node.js / lint-js (push) Successful in 12s
DRB Tests / drb_mocha_tests (push) Successful in 31s
2024-08-18 01:29:23 -04:00
Logan Cusano
f70ea4229a Trying node dev #25
Some checks failed
DRB Tests / drb_mocha_tests (push) Has been cancelled
Lint JavaScript/Node.js / lint-js (push) Has been cancelled
Update Wiki from JSDoc / update-wiki (push) Has been cancelled
release-tag / release-image (push) Successful in 2m4s
2024-08-18 01:27:01 -04:00
Logan Cusano
acadc9faee Another attempt #25
Some checks failed
release-tag / release-image (push) Successful in 2m1s
Update Wiki from JSDoc / update-wiki (push) Failing after 11s
Lint JavaScript/Node.js / lint-js (push) Successful in 11s
DRB Tests / drb_mocha_tests (push) Successful in 29s
2024-08-18 01:23:14 -04:00
Logan Cusano
f725ec88f9 Sepcify dir for #25
All checks were successful
release-tag / release-image (push) Successful in 2m1s
Update Wiki from JSDoc / update-wiki (push) Successful in 12s
Lint JavaScript/Node.js / lint-js (push) Successful in 11s
DRB Tests / drb_mocha_tests (push) Successful in 27s
2024-08-18 01:05:05 -04:00
Logan Cusano
8d34b93527 Hopefully fix for action issue #25
All checks were successful
release-tag / release-image (push) Successful in 2m1s
Update Wiki from JSDoc / update-wiki (push) Successful in 12s
Lint JavaScript/Node.js / lint-js (push) Successful in 11s
DRB Tests / drb_mocha_tests (push) Successful in 28s
2024-08-18 01:00:38 -04:00
Logan Cusano
918cfe06e4 More debug for #25
All checks were successful
release-tag / release-image (push) Successful in 2m4s
Update Wiki from JSDoc / update-wiki (push) Successful in 13s
Lint JavaScript/Node.js / lint-js (push) Successful in 11s
DRB Tests / drb_mocha_tests (push) Successful in 26s
2024-08-18 00:43:44 -04:00
Logan Cusano
e2f276e65b #25
All checks were successful
release-tag / release-image (push) Successful in 2m4s
Update Wiki from JSDoc / update-wiki (push) Successful in 14s
Lint JavaScript/Node.js / lint-js (push) Successful in 11s
DRB Tests / drb_mocha_tests (push) Successful in 27s
2024-08-18 00:36:02 -04:00
52353ec1fb Merge pull request '#22 - Add Automated Docs' (#24) from automated-docs-#22 into main
All checks were successful
release-tag / release-image (push) Successful in 2m2s
Update Wiki from JSDoc / update-wiki (push) Successful in 13s
Lint JavaScript/Node.js / lint-js (push) Successful in 11s
DRB Tests / drb_mocha_tests (push) Successful in 26s
Reviewed-on: #24
2024-08-17 19:48:46 -04:00
Logan Cusano
750877db1a Remove docs on PRs
All checks were successful
Lint JavaScript/Node.js / lint-js (pull_request) Successful in 11s
DRB Tests / drb_mocha_tests (pull_request) Successful in 28s
- Update wiki step
2024-08-17 19:46:15 -04:00
Logan Cusano
a18337d0f8 Updated 'home' -> 'Home'
All checks were successful
Update Wiki from JSDoc / update-wiki (pull_request) Successful in 12s
Lint JavaScript/Node.js / lint-js (pull_request) Successful in 11s
DRB Tests / drb_mocha_tests (pull_request) Successful in 29s
2024-08-17 19:40:18 -04:00
Logan Cusano
6f45a60030 Update action to force copy
Some checks failed
Update Wiki from JSDoc / update-wiki (pull_request) Failing after 11s
Lint JavaScript/Node.js / lint-js (pull_request) Successful in 10s
DRB Tests / drb_mocha_tests (pull_request) Successful in 26s
2024-08-17 19:33:06 -04:00
Logan Cusano
1fb4728b0a Revert incomplete changes to GPT handler
Some checks failed
Update Wiki from JSDoc / update-wiki (pull_request) Failing after 11s
Lint JavaScript/Node.js / lint-js (pull_request) Successful in 11s
DRB Tests / drb_mocha_tests (pull_request) Successful in 28s
2024-08-17 19:28:44 -04:00
Logan Cusano
ebf48c7618 Linting 2024-08-17 19:27:48 -04:00
Logan Cusano
11b3504f28 Update docs for test
Some checks failed
Update Wiki from JSDoc / update-wiki (pull_request) Successful in 12s
Lint JavaScript/Node.js / lint-js (pull_request) Failing after 10s
DRB Tests / drb_mocha_tests (pull_request) Successful in 29s
2024-08-17 19:15:02 -04:00
Logan Cusano
14171a9c13 Fix homepage name 2024-08-17 19:13:44 -04:00
Logan Cusano
47a03898cc Update action and npm script
Some checks failed
Update Wiki from JSDoc / update-wiki (pull_request) Successful in 12s
Lint JavaScript/Node.js / lint-js (pull_request) Failing after 10s
DRB Tests / drb_mocha_tests (pull_request) Successful in 26s
2024-08-17 19:10:56 -04:00
Logan Cusano
2551498d2e update npx -> npm
Some checks failed
Update Wiki from JSDoc / update-wiki (pull_request) Failing after 10s
Lint JavaScript/Node.js / lint-js (pull_request) Failing after 11s
DRB Tests / drb_mocha_tests (pull_request) Successful in 29s
2024-08-17 19:07:23 -04:00
Logan Cusano
277f7d176a Update docs to work
Some checks failed
Update Wiki from JSDoc / update-wiki (pull_request) Has been cancelled
Lint JavaScript/Node.js / lint-js (pull_request) Has been cancelled
DRB Tests / drb_mocha_tests (pull_request) Has been cancelled
2024-08-17 19:05:38 -04:00
Logan Cusano
066404dd10 Updated dir structure to put the actual source code in the general /src dir
Some checks failed
Update Wiki from JSDoc / update-wiki (pull_request) Has been cancelled
Lint JavaScript/Node.js / lint-js (pull_request) Failing after 11s
DRB Tests / drb_mocha_tests (pull_request) Has been cancelled
2024-08-17 18:44:18 -04:00
Logan Cusano
8f2891f5d8 Update docs to use npm script for consistency 2024-08-17 18:43:39 -04:00
Logan Cusano
9f2ed48caf Added better docs
Some checks failed
Lint JavaScript/Node.js / lint-js (pull_request) Failing after 14s
DRB Tests / drb_mocha_tests (pull_request) Successful in 34s
Update Wiki from JSDoc / update-wiki (pull_request) Successful in 15s
2024-08-17 18:11:38 -04:00
Logan Cusano
3f42d60efc Add docs to ignored file for this repo 2024-08-17 18:11:14 -04:00
Logan Cusano
cf9f48dfa7 Fix jsdoc bug
Some checks failed
Update Wiki from JSDoc / update-wiki (pull_request) Failing after 10s
Lint JavaScript/Node.js / lint-js (pull_request) Failing after 10s
DRB Tests / drb_mocha_tests (pull_request) Successful in 25s
- Was importing class within the jsdoc
2024-08-17 17:56:25 -04:00
Logan Cusano
bde7dbce45 add pr to docs for testing
Some checks failed
Update Wiki from JSDoc / update-wiki (pull_request) Failing after 10s
Lint JavaScript/Node.js / lint-js (pull_request) Successful in 11s
DRB Tests / drb_mocha_tests (pull_request) Successful in 25s
2024-08-17 17:53:32 -04:00
46 changed files with 2131 additions and 40 deletions

View File

@@ -7,6 +7,10 @@ on:
# schedule:
# - cron: '0 0 * * 1' # Every Monday at midnight (UTC)
env:
NODE_ENV: development
jobs:
update-wiki:
runs-on: ubuntu-latest
@@ -23,7 +27,7 @@ jobs:
run: npm install
- name: Generate JSDoc
run: npx jsdoc -c jsdoc.json -d docs
run: npm run docs
- name: Checkout the wiki repository
uses: actions/checkout@v4
@@ -31,12 +35,22 @@ jobs:
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 -r docs/* wiki/
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 .
git commit -m "Update wiki from JSDoc"
git push
# 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
.gitignore vendored
View File

@@ -301,4 +301,7 @@ config/
op25/
# Ignore any local run scripts for development
*.bat
*.bat
# Ignore the auto-generated docs folder
/docs

View File

@@ -12,7 +12,7 @@ RUN npm install -g node-gyp
RUN npm install
# 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 3420

View File

@@ -17,7 +17,7 @@ export default [
// Apply ESLint recommended settings first
...compat.extends().map((config) => ({
...config,
files: ["**/*.mjs", "**/*.js", "**/*.cjs"],
files: ["src/**/*.mjs", "src/**/*.js", "src/**/*.cjs"],
})),
// Custom rules and plugin configuration

10
jsdoc.conf Normal file
View File

@@ -0,0 +1,10 @@
{
"source": {
"includePattern": ".+([mc]?js(doc|x)?)$"
},
"plugins": ["node_modules/jsdoc-babel"],
"babel": {
"presets": [ "es2015" ],
"plugins": [ "transform-async-to-generator" ]
}
}

View File

@@ -1,14 +0,0 @@
{
"source": {
"include": ["addons", "discordBot", "modules", "rss-manager", "test"],
"exclude": ["node_modules"],
"includePattern": ".+\\.[mc]?js(doc|x)?$",
"excludePattern": "(^|\\/|\\\\)_"
},
"opts": {
"destination": "./docs",
"recurse": true,
"template": "default"
}
}

View File

@@ -21,10 +21,6 @@ run:
-e MONGO_URL=${MONGO_URL} \
-e DISCORD_TOKEN=${DISCORD_TOKEN} \
-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 LOG_LOCATION="./logs/server.log" \
-p ${SERVER_PORT}:${SERVER_PORT} \

2058
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,23 +2,27 @@
"name": "drb-server",
"version": "3.0.0",
"description": "",
"main": "server.js",
"main": "src/server.js",
"scripts": {
"docs": "jsdoc2md -c jsdoc.conf src/*js > Home.md",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"test": "mocha --timeout 5000",
"start": "node server.js"
"start": "node src/server.js"
},
"author": "Logan Cusano",
"license": "ISC",
"type": "module",
"devDependencies": {
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"chai": "^5.1.1",
"eslint": "^9.9.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-unused-imports": "^4.1.3",
"jsdoc": "^4.0.3",
"jsdoc-babel": "^0.5.0",
"jsdoc-to-markdown": "^8.0.3",
"mocha": "^10.4.0",
"prettier": "^3.3.3",
"socket.io-client": "^4.7.5"

View File

@@ -4,10 +4,13 @@ import {
} from "../../modules/mongo-wrappers/mongoConfigWrappers.mjs";
import { ActivityType, PresenceUpdateStatus } from "discord.js";
/**
* Control the presence or activity of the discord bot.
*/
class 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) {
this.client = client;

View File

@@ -4,7 +4,6 @@ import {
checkIfNodeIsConnectedToVC,
getNodeDiscordID,
getNodeDiscordUsername,
checkIfNodeHasOpenDiscordClient,
getNodeCurrentListeningSystem,
requestNodeJoinSystem,
} from "../../modules/socketServerWrappers.mjs";
@@ -86,9 +85,8 @@ export const getAvailableNodes = async (nodeIo, guildId, system) => {
openSockets.map(async (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)
const hasOpenClient = await checkIfNodeHasOpenDiscordClient(openSocket);
if (hasOpenClient) {
let currentSystem = await getNodeCurrentListeningSystem(openSocket);
let currentSystem = await getNodeCurrentListeningSystem(openSocket);
if (currentSystem) {
if (currentSystem != system.name) {
log.INFO(
"Node is listening to a different system than requested",

View File

@@ -71,6 +71,22 @@ export const updateFeedByLink = async (link, updatedFields) => {
}
};
// Wrapper for deactivating a feed by link
export const deactivateFeedByLink = async (link) => {
try {
const updatedCount = await updateDocumentByField(
feedCollectionName,
"link",
link,
[{'active':false}]
);
return updatedCount;
} catch (error) {
log.ERROR("Error deleting feed by link:", error);
throw error;
}
};
// Wrapper for deleting a feed by link
export const deleteFeedByLink = async (link) => {
try {

View File

@@ -51,6 +51,10 @@ export const updateFeeds = async (client) => {
const sourcePromiseArray = records.map(async (source) => {
log.DEBUG("Processing source:", source.title);
// Check if the feed is active
if (!source.active) {
return
}
try {
const parsedFeed = await parser.parseURL(source.link);

View File

@@ -3,7 +3,7 @@ const log = new DebugBuilder("server", "sourceManager");
import {
createFeed,
getFeedByLink,
deleteFeedByLink,
deactivateFeedByLink,
} from "../modules/mongo-wrappers/mongoFeedsWrappers.mjs";
class SourceManager {
@@ -48,7 +48,7 @@ class SourceManager {
return;
}
const results = await deleteFeedByLink(sourceURL);
const results = await deactivateFeedByLink(sourceURL);
if (!results) {
log.WARN(`Failed to remove source: ${sourceURL}`);
return;
@@ -70,6 +70,7 @@ class SourceManager {
category,
guild_id: guildId,
channel_id: channelId,
active: true
};
const record = await createFeed(feed);
log.DEBUG("Source added:", record);

View File

@@ -4,11 +4,11 @@ import ioClient from "socket.io-client";
import {
deleteNodeByNuid,
getNodeByNuid,
} from "../modules/mongo-wrappers/mongoNodesWrappers.mjs";
} from "../src/modules/mongo-wrappers/mongoNodesWrappers.mjs";
import {
deleteSystemByName,
getSystemByName,
} from "../modules/mongo-wrappers/mongoSystemsWrappers.mjs";
} from "../src/modules/mongo-wrappers/mongoSystemsWrappers.mjs";
import {
nodeDisconnectWrapper,
checkIfNodeHasOpenDiscordClient,
@@ -19,8 +19,8 @@ import {
requestBotLeaveServer,
requestNodeJoinSystem,
requestNodeUpdate,
} from "../modules/socketServerWrappers.mjs";
import { nodeIo } from "../modules/socketServer.mjs";
} from "../src/modules/socketServerWrappers.mjs";
import { nodeIo } from "../src/modules/socketServer.mjs";
import dotenv from "dotenv";
dotenv.config();