From d70abc50924c5b19b4de76694ea3bb1ec8866ccc Mon Sep 17 00:00:00 2001 From: Histmy Date: Tue, 18 Mar 2025 13:18:24 +0100 Subject: [PATCH] =?UTF-8?q?konec=20logov=C3=A1n=C3=AD=20u=C5=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.ts | 6 --- src/utils/statuslog.ts | 92 ------------------------------------------ 2 files changed, 98 deletions(-) delete mode 100644 src/utils/statuslog.ts diff --git a/src/app.ts b/src/app.ts index 85c6b33..3812e46 100644 --- a/src/app.ts +++ b/src/app.ts @@ -5,7 +5,6 @@ import { adminLog, areStatusesSame, formatCas, log, nabidni, oddiakritikovat, pr import levenshtein from "js-levenshtein"; import { emouty } from "./utils/emotes"; import { lidiCoMajDenimPremium, setClient } from "./utils/denim-Spravce"; -import { logOOoZS, logSZS, logPZS } from "./utils/statuslog"; const ints = GatewayIntentBits; const client = new Client({ @@ -349,19 +348,14 @@ client.on("presenceUpdate", async (bef, aft) => { if (!user) return; if (!user.presence) user.presence = {}; - logOOoZS(user.id, aft.clientStatus); - if (areStatusesSame(aft.clientStatus, user.presence)) return; - logSZS(user.id, aft.clientStatus); - const naCo = aft.clientStatus || {}; user.presence = naCo; await new Promise(r => setTimeout(r, 1000)); if (!areStatusesSame(naCo, user.presence)) { - logPZS(user.id, naCo, user.presence); return; } diff --git a/src/utils/statuslog.ts b/src/utils/statuslog.ts deleted file mode 100644 index 828a7ee..0000000 --- a/src/utils/statuslog.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { ClientPresenceStatusData } from "discord.js"; -import { appendFileSync } from "fs"; -import { SRecord } from "./types"; - -const cesta = "statlog.dlog"; - -appendFileSync(cesta, "\n\n\nDLOG3.0\n"); - -let aktualniOffset: number; -const lidiVDLOG3 = new Map(); - -function updateOffset() { - aktualniOffset = Date.now(); - appendFileSync(cesta, `T${aktualniOffset.toString(36)}\n`); -} -setInterval(updateOffset, 27 * 60 * 1000); -updateOffset(); - -export function getDLOGTimestamp() { - return (Date.now() - aktualniOffset).toString(36); -} - -export function getIdInDLOG3(id: string) { - if (lidiVDLOG3.has(id)) // Pokud už je v mapě - return lidiVDLOG3.get(id); - - // Pokud není v mapě vygenerujeme nové ID a uložíme do mapy - let letters = ''; - let num = lidiVDLOG3.size + 1; - while (num > 0) { - num--; // Adjust for 0-indexing - // Get the remainder and convert to a character - letters = String.fromCharCode((num % 26) + 65) + letters; - // Divide by 26 for the next iteration - num = Math.floor(num / 26); - } - - lidiVDLOG3.set(id, letters); - - return `${letters}${id}`; -} - -const platformTable: SRecord = { - desktop: "D", - web: "W", - mobile: "M" -}; - -const statusTable: SRecord = { - online: 1, - idle: 2, - dnd: 3 -}; - -export function statusToDLOG3(status: ClientPresenceStatusData | null) { - if (!status) return "-"; - - const tovje = []; - - for (const [key, value] of Object.entries(status)) { - const platform = platformTable[key] ?? key; - const status = statusTable[value] ?? 0; - if (status) tovje.push(`${platform} ${status}`); - } - - if (!tovje.length) return "-"; - - return tovje.join(" "); -} - -// Logování Obecného oznámení o změně statusu -export function logOOoZS(userId: string, status: ClientPresenceStatusData | null) { - const timestamp = getDLOGTimestamp(); - const id = getIdInDLOG3(userId); - const stat = statusToDLOG3(status); - appendFileSync(cesta, `${timestamp}${id}o${stat}\n`); -} - -// Logování Skutečné změny statusu -export function logSZS(userId: string, status: ClientPresenceStatusData | null) { - const id = getIdInDLOG3(userId); - const stat = statusToDLOG3(status); - appendFileSync(cesta, `${id}s${stat}\n`); -} - -// Logování Podezřelé změny statusu -export function logPZS(userId: string, status1: ClientPresenceStatusData | null, status2: ClientPresenceStatusData | null) { - const id = getIdInDLOG3(userId); - const stat1 = statusToDLOG3(status1); - const stat2 = statusToDLOG3(status2); - appendFileSync(cesta, `${id}p${stat1}|${stat2}\n`); -}