Compare commits
4 Commits
developmen
...
55e3f5a3c4
| Author | SHA1 | Date | |
|---|---|---|---|
| 55e3f5a3c4 | |||
| 496bc61c7d | |||
| 204616a2d8 | |||
| 5770f28acb |
@ -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());
|
||||||
|
|||||||
@ -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 }};
|
||||||
|
|||||||
@ -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", ()=>{
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
25
index.js
25
index.js
@ -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,9 +77,10 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -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"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -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 * * *',
|
||||||
|
|||||||
33
websocket.js
Normal file
33
websocket.js
Normal 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);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user