Compare commits

..

5 Commits

Author SHA1 Message Date
sky
39cdf17e3e close socket 2025-10-26 15:30:09 -04:00
sky
55e3f5a3c4 fix websocket server 2025-10-26 15:21:43 -04:00
sky
496bc61c7d remove ads from some places 2025-10-26 14:47:13 -04:00
sky
204616a2d8 fix 2025-10-26 14:21:18 -04:00
sky
5770f28acb Merge pull request 'v2' (#1) from development into main
Reviewed-on: #1
2025-10-26 12:54:21 -04:00
9 changed files with 57 additions and 12 deletions

View File

@ -271,6 +271,7 @@ async function generateAccountPage(name, cookie, admin) {
} }
let modifiedHTML = rawProfileHTML; let modifiedHTML = rawProfileHTML;
console.log(userData.music);
let songData = JSON.parse(userData.music) || false; let songData = JSON.parse(userData.music) || false;
modifiedHTML = modifiedHTML.replaceAll("{{ name }}", sanitizeHtml(userData.name, allowNone)); modifiedHTML = modifiedHTML.replaceAll("{{ name }}", sanitizeHtml(userData.name, allowNone));
modifiedHTML = modifiedHTML.replaceAll("{{ join_date }}", dayjs(userData.createdAt).fromNow()); modifiedHTML = modifiedHTML.replaceAll("{{ join_date }}", dayjs(userData.createdAt).fromNow());

View File

@ -44,7 +44,6 @@
<!-- seo + other things --> <!-- seo + other things -->
<title>{{ name }}'s Profile | Selenite</title> <title>{{ name }}'s Profile | Selenite</title>
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3415518411898563" crossorigin="anonymous"></script>
<script> <script>
document.addEventListener("DOMContentLoaded", ()=>{ document.addEventListener("DOMContentLoaded", ()=>{
let music = {{ is_music }}; let music = {{ is_music }};

View File

@ -44,7 +44,6 @@
<!-- seo + other things --> <!-- seo + other things -->
<title>{{ name }}'s Profile | Selenite</title> <title>{{ name }}'s Profile | Selenite</title>
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3415518411898563" crossorigin="anonymous"></script>
<!-- <script> <!-- <script>
let audioObject; let audioObject;
document.addEventListener("DOMContentLoaded", ()=>{ document.addEventListener("DOMContentLoaded", ()=>{

View File

@ -123,7 +123,7 @@
}); });
</script> </script>
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3415518411898563" crossorigin="anonymous"></script>
</head> </head>
<alerts> </alerts> <alerts> </alerts>
<body> <body>

View File

@ -45,10 +45,20 @@ import WebSocket, { WebSocketServer } from "ws";
const wss = new WebSocketServer({ noServer: true }); const wss = new WebSocketServer({ noServer: true });
// let openSockets = 0; // let openSockets = 0;
wss.on("connection", function connection(ws, req, res) { wss.on("connection", function connection(ws, req, res) {
ws.send(`online=${wss.clients.size}`); // ws.send(`online=${wss.clients.size}`);
setInterval(() => { // setInterval(() => {
ws.send(`online=${wss.clients.size}`); // ws.send(`online=${wss.clients.size}`);
}, 10000); // }, 10000);
let server = new WebSocket("ws://localhost:7910");
server.on("message", async function message(data) {
let message = Buffer.from(data).toString();
if(message.startsWith("online")) {
ws.send(message);
} else if(message.startsWith("annc")) {
ws.send(message);
}
})
ws.on("error", console.error); ws.on("error", console.error);
@ -67,14 +77,15 @@ wss.on("connection", function connection(ws, req, res) {
} else if (message.startsWith("annc")) { } else if (message.startsWith("annc")) {
let splitMessage = message.split(";;"); let splitMessage = message.split(";;");
if(await isAdmin(splitMessage[1])) { if(await isAdmin(splitMessage[1])) {
wss.clients.forEach(client => { // wss.clients.forEach(client => {
client.send(`annc;;${splitMessage[2]};;${splitMessage[3]}`); // client.send(`annc;;${splitMessage[2]};;${splitMessage[3]}`);
}) // })
server.send(message);
} }
} }
}); });
ws.on("close", () => {}); ws.on("close", () => {server.close()});
}); });
app.post( app.post(
"/api/event", "/api/event",

View File

@ -4,6 +4,7 @@
"description": "", "description": "",
"exports": "./index.js", "exports": "./index.js",
"scripts": { "scripts": {
"websocket_server": "bun --watch websocket.js",
"start": "bun --watch index.js", "start": "bun --watch index.js",
"svg": "node svg-converter.js" "svg": "node svg-converter.js"
}, },

View File

@ -1,6 +1,6 @@
module.exports = { module.exports = {
name: "Selenite", // Name of your application name: "Selenite", // Name of your application
script: "index.js", // Entry point of your application script: "start.cjs", // Entry point of your application
interpreter: "bun", // Path to the Bun interpreter interpreter: "bun", // Path to the Bun interpreter
watch: true, watch: true,
cron_restart: '0 0 * * *', cron_restart: '0 0 * * *',

1
start.cjs Normal file
View File

@ -0,0 +1 @@
import('./index.js');

33
websocket.js Normal file
View File

@ -0,0 +1,33 @@
import WebSocket, { WebSocketServer } from "ws";
const wss = new WebSocketServer({ noServer: true });
wss.on("connection", function connection(ws, req, res) {
ws.send(`online=${wss.clients.size}`);
setInterval(() => {
ws.send(`online=${wss.clients.size}`);
}, 10000);
ws.on("message", async function message(data, isBinary) {
let message = Buffer.from(data).toString();
if (message.startsWith("annc")) {
let splitMessage = message.split(";;");
wss.clients.forEach(client => {
client.send(`annc;;${splitMessage[2]};;${splitMessage[3]}`);
})
}
});
ws.on("close", () => {});
});
let port = 7910;
import express from "express";
const app = express();
const server = app.listen(port, () => {
console.log("Websocket server is online.");
console.log("- http://localhost:" + port);
});
server.on("upgrade", (request, socket, head) => {
wss.handleUpgrade(request, socket, head, (socket) => {
wss.emit("connection", socket, request);
});
});