This commit is contained in:
James Shiffer 2024-02-06 16:48:58 -08:00
commit a68f632125
6 changed files with 35 additions and 26 deletions

2
.env
View File

@ -1 +1 @@
PORT=3000 PORT=5555

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
**/.env **/.env
**/*.js **/*.js
**/*.js.map **/*.js.map
**/nohup.out
# Logs # Logs
logs logs

View File

@ -16,6 +16,8 @@ import {
User User
} from 'discord.js'; } from 'discord.js';
import { ChatMessage, llamacpp, streamText } from 'modelfusion'; import { ChatMessage, llamacpp, streamText } from 'modelfusion';
import fetch from 'node-fetch';
import { JSDOM } from 'jsdom';
import { logError, logInfo } from '../logging'; import { logError, logInfo } from '../logging';
import { import {
db, db,
@ -78,8 +80,8 @@ async function fetchMotd()
{ {
const res = await fetch(process.env.MOTD_HREF); const res = await fetch(process.env.MOTD_HREF);
const xml = await res.text(); const xml = await res.text();
const parser = new DOMParser(); const parser = new JSDOM(xml);
const doc = parser.parseFromString(xml, 'text/html'); const doc = parser.window.document;
return doc.querySelector(process.env.MOTD_QUERY).textContent; return doc.querySelector(process.env.MOTD_QUERY).textContent;
} }

View File

@ -5,6 +5,8 @@
"discord.js": "^14.13.0", "discord.js": "^14.13.0",
"dotenv": "^16.3.1", "dotenv": "^16.3.1",
"modelfusion": "^0.135.1", "modelfusion": "^0.135.1",
"jsdom": "^22.1.0",
"node-fetch": "^3.3.2",
"sqlite": "^5.0.1", "sqlite": "^5.0.1",
"sqlite3": "^5.1.6" "sqlite3": "^5.1.6"
}, },

46
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "femleaderboard", "name": "femscoreboard",
"version": "0.0.0", "version": "1.0.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "femleaderboard", "name": "femscoreboard",
"version": "0.0.0", "version": "1.0.0",
"dependencies": { "dependencies": {
"dotenv": "^16.3.1", "dotenv": "^16.3.1",
"express": "^4.18.2", "express": "^4.18.2",
@ -84,6 +84,25 @@
"node-pre-gyp": "bin/node-pre-gyp" "node-pre-gyp": "bin/node-pre-gyp"
} }
}, },
"node_modules/@mapbox/node-pre-gyp/node_modules/node-fetch": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/@npmcli/fs": { "node_modules/@npmcli/fs": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-1.1.1.tgz", "resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-1.1.1.tgz",
@ -1319,25 +1338,6 @@
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-4.3.0.tgz", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-4.3.0.tgz",
"integrity": "sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ==" "integrity": "sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ=="
}, },
"node_modules/node-fetch": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/node-gyp": { "node_modules/node-gyp": {
"version": "8.4.1", "version": "8.4.1",
"resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-8.4.1.tgz", "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-8.4.1.tgz",

4
start.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
nohup npm start &
cd discord
nohup npm start