diff --git a/.env b/.env index 2fc80e3..a8a6553 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -PORT=3000 +PORT=5555 diff --git a/.gitignore b/.gitignore index 79e658c..0c62001 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ **/.env **/*.js **/*.js.map +**/nohup.out # Logs logs diff --git a/discord/bot.ts b/discord/bot.ts index 6252cd8..77db3bc 100644 --- a/discord/bot.ts +++ b/discord/bot.ts @@ -16,6 +16,8 @@ import { User } from 'discord.js'; import { ChatMessage, llamacpp, streamText } from 'modelfusion'; +import fetch from 'node-fetch'; +import { JSDOM } from 'jsdom'; import { logError, logInfo } from '../logging'; import { db, @@ -78,8 +80,8 @@ async function fetchMotd() { const res = await fetch(process.env.MOTD_HREF); const xml = await res.text(); - const parser = new DOMParser(); - const doc = parser.parseFromString(xml, 'text/html'); + const parser = new JSDOM(xml); + const doc = parser.window.document; return doc.querySelector(process.env.MOTD_QUERY).textContent; } diff --git a/discord/package.json b/discord/package.json index a882789..96057be 100644 --- a/discord/package.json +++ b/discord/package.json @@ -5,6 +5,8 @@ "discord.js": "^14.13.0", "dotenv": "^16.3.1", "modelfusion": "^0.135.1", + "jsdom": "^22.1.0", + "node-fetch": "^3.3.2", "sqlite": "^5.0.1", "sqlite3": "^5.1.6" }, diff --git a/package-lock.json b/package-lock.json index 4aabb8b..01eb24f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "femleaderboard", - "version": "0.0.0", + "name": "femscoreboard", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "femleaderboard", - "version": "0.0.0", + "name": "femscoreboard", + "version": "1.0.0", "dependencies": { "dotenv": "^16.3.1", "express": "^4.18.2", @@ -84,6 +84,25 @@ "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": { "version": "1.1.1", "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", "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": { "version": "8.4.1", "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-8.4.1.tgz", diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..c76e267 --- /dev/null +++ b/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +nohup npm start & +cd discord +nohup npm start