konec logování už
This commit is contained in:
parent
cbde2fd537
commit
d70abc5092
@ -5,7 +5,6 @@ import { adminLog, areStatusesSame, formatCas, log, nabidni, oddiakritikovat, pr
|
|||||||
import levenshtein from "js-levenshtein";
|
import levenshtein from "js-levenshtein";
|
||||||
import { emouty } from "./utils/emotes";
|
import { emouty } from "./utils/emotes";
|
||||||
import { lidiCoMajDenimPremium, setClient } from "./utils/denim-Spravce";
|
import { lidiCoMajDenimPremium, setClient } from "./utils/denim-Spravce";
|
||||||
import { logOOoZS, logSZS, logPZS } from "./utils/statuslog";
|
|
||||||
|
|
||||||
const ints = GatewayIntentBits;
|
const ints = GatewayIntentBits;
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
@ -349,19 +348,14 @@ client.on("presenceUpdate", async (bef, aft) => {
|
|||||||
if (!user) return;
|
if (!user) return;
|
||||||
if (!user.presence) user.presence = {};
|
if (!user.presence) user.presence = {};
|
||||||
|
|
||||||
logOOoZS(user.id, aft.clientStatus);
|
|
||||||
|
|
||||||
if (areStatusesSame(aft.clientStatus, user.presence)) return;
|
if (areStatusesSame(aft.clientStatus, user.presence)) return;
|
||||||
|
|
||||||
logSZS(user.id, aft.clientStatus);
|
|
||||||
|
|
||||||
const naCo = aft.clientStatus || {};
|
const naCo = aft.clientStatus || {};
|
||||||
user.presence = naCo;
|
user.presence = naCo;
|
||||||
|
|
||||||
await new Promise(r => setTimeout(r, 1000));
|
await new Promise(r => setTimeout(r, 1000));
|
||||||
|
|
||||||
if (!areStatusesSame(naCo, user.presence)) {
|
if (!areStatusesSame(naCo, user.presence)) {
|
||||||
logPZS(user.id, naCo, user.presence);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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<string, string>();
|
|
||||||
|
|
||||||
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<string> = {
|
|
||||||
desktop: "D",
|
|
||||||
web: "W",
|
|
||||||
mobile: "M"
|
|
||||||
};
|
|
||||||
|
|
||||||
const statusTable: SRecord<number> = {
|
|
||||||
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`);
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user