Compare commits

...

10 Commits

Author SHA1 Message Date
Histmy
fda8571cbe tak to si nacpi moje velký káro, do hubyy 2023-11-12 11:30:41 +01:00
Histmy
88022bd15f Logy chyby, DM chyby a mnohem lepší start.sh 2023-10-21 23:40:23 +02:00
Histmy
ff3d928a41 a retardismus stále jede 2023-10-03 21:15:08 +02:00
Histmy
b09cf48709 prostě pičus pokračuje 2023-10-03 20:04:22 +02:00
Histmy
d78ff668fe pičus klasicky 2023-10-03 18:58:37 +02:00
Histmy
567fe18bac fejk spink 2023-10-03 18:56:42 +02:00
Histmy
77812f7a43
aliasy i více stránek nyní 2023-09-10 18:13:57 +02:00
Histmy
29aefdd3da
fakt 2MB 2023-09-09 20:23:14 +02:00
Histmy
6d39dc89b2
random hovna 2023-09-09 18:48:54 +02:00
Histmy
61f67a86f0
max 13 vteřin zvuk při příchodu 2023-09-07 19:56:01 +02:00
12 changed files with 775 additions and 712 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ res/customKomandy.json
res/customAliasy.json
zaznamy.dlog
zvuky/priVstupu
logs

1343
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "denim_3001",
"version": "3001.54.0",
"version": "3001.54.4",
"description": "Toto je velmi kvalitní bot.",
"repository": {
"url": "https://github.com/Histmy/Denim-Bot/"
@ -15,7 +15,7 @@
"license": "ISC",
"dependencies": {
"@discordjs/voice": "^0.16.0",
"discord.js": "^14.11.0",
"discord.js": "^14.13.0",
"js-levenshtein": "^1.1.6",
"mysql": "^2.18.1",
"node-fetch": "^2.6.1",
@ -23,13 +23,13 @@
"play-dl": "^1.9.6",
"tiny-typed-emitter": "^2.1.0",
"tweetnacl": "^1.0.3",
"valibot": "^0.13.1"
"valibot": "^0.14.0"
},
"devDependencies": {
"@types/jest": "^29.5.3",
"@types/jest": "^29.5.4",
"@types/js-levenshtein": "^1.1.1",
"@types/mysql": "^2.15.21",
"@types/node-fetch": "^2.6.4",
"jest": "^29.6.1"
"jest": "^29.6.4"
}
}

View File

@ -4,7 +4,7 @@ import { CUser, KomandNaExport, Komand, ListenerFunkce, Modul, SRecord, SuperLis
import { adminLog, formatCas, oddiakritikovat, log, rand, prefix, nabidni } from "./utils/utils.js";
import levenshtein from "js-levenshtein";
import { emouty } from "./utils/emotes";
import { lidiCoMajDenimPremium } from "./utils/denim-Spravce";
import { lidiCoMajDenimPremium, setClient } from "./utils/denim-Spravce";
const ints = GatewayIntentBits;
const client = new Client({
@ -21,6 +21,7 @@ const helpServer: HelpServer = require("./utils/helpServer");
client.komandy = {};
client.aliasy = {};
setClient(client);
function getFirstArg(fn: KomandRaw["run"]) {
if (typeof fn != "function") return;
@ -38,7 +39,7 @@ const runEvent = (name: string, args: unknown[]) => {
} catch (e) {
if (process.env.dieOnError) throw e;
log("error pri spusteni super listeneru", e as Error);
adminLog(client, "error pri supereventu");
adminLog(client, "error pri supereventu", e as Error);
}
}
@ -48,7 +49,7 @@ const runEvent = (name: string, args: unknown[]) => {
} catch (e) {
if (process.env.dieOnError) throw e;
log("error pri spousteni eventu", e as Error);
adminLog(client, "error pri eventu");
adminLog(client, "error pri eventu", e as Error);
}
});
};

View File

@ -281,7 +281,7 @@ const exp: Modul = {
fields: [{ name: zacatekNazvu, value: `${stranky[0].join("\n• ")}` }]
};
if (celkovadylka <= 1024) return { embeds: [embed] };
if (stranky.length == 1) return { embeds: [embed] };
embed.fields![0].name += ` (1/${stranky.length})`;

View File

@ -1,16 +1,22 @@
import { getVoiceConnection } from "@discordjs/voice";
import { Modul } from "../utils/types";
import { rmSync, readdirSync, writeFileSync } from "fs";
import { renameSync, rmSync, readdirSync, writeFileSync } from "fs";
import { join } from "path";
import { Priority, novejPlay } from "../utils/voice";
import { lidiCoMajDenimPremium, semMiDejClienta } from "../utils/denim-Spravce";
import { lidiCoMajDenimPremium } from "../utils/denim-Spravce";
import fetch from "node-fetch";
import { exec } from "child_process";
import { log } from "../utils/utils";
// Extrémní fekál, jestli má někdo lepsí nápad, sem s ním
semMiDejClienta.client = module.exports.client;
const kmenovaCesta = join(__dirname, `../../zvuky/priVstupu`);
const formaty = ["mp3", "wav", "ogg"];
function vymaz(path: string) {
try {
rmSync(path);
} catch { }
}
const exp: Modul = {
more_komandy: {
@ -23,19 +29,42 @@ const exp: Modul = {
if (!soubor) return "tak pico ael na co";
if (!formaty.includes(soubor.name.slice(-3))) return "tuten format nechcy";
if (soubor.size > 2e6) return "min nes dva mebagajyt pls";
if (soubor.size > 2_097_152) return "min nes dva mebagajyt pls";
const zaklad = `${kmenovaCesta}/${mes.author.id}`;
for (const format of formaty) {
try {
rmSync(`${zaklad}.${format}`);
} catch { }
}
// Stahnout dočasně
const typ = soubor.name.slice(-3);
const docasnaCesta = `${kmenovaCesta}/temp${Math.round(Math.random() * 1000)}.${typ}`;
const odpoved = await fetch(soubor.url).then(r => r.arrayBuffer());
writeFileSync(`${zaklad}.${soubor.name.slice(-3)}`, new DataView(odpoved));
writeFileSync(docasnaCesta, new DataView(odpoved));
return "ej tot am";
// Zjistit running-time
exec(`ffprobe -i ${docasnaCesta} -show_entries format=duration -v quiet -of csv="p=0"`, (error, stdout) => {
if (error) {
log("chyba pri ffprobe", error);
mes.channel.send("bohuzel chiba");
vymaz(docasnaCesta);
return;
}
// Maximum
if (Number(stdout) > 13) {
mes.channel.send("13 se kund maks");
vymaz(docasnaCesta);
return;
}
// Smazat starej (nevíme formát, tak musíme zkust všechny)
const zaklad = `${kmenovaCesta}/${mes.author.id}`;
for (const format of formaty) {
vymaz(`${zaklad}.${format}`);
}
renameSync(docasnaCesta, `${zaklad}.${typ}`);
mes.channel.send("ej tot am");
});
}
}
},

View File

@ -35,7 +35,7 @@ async function playNext(guildId: string, seek?: number) {
log(e);
const client: Client = module.exports.client;
adminLog(client, "error v hani muziky");
adminLog(client, "error v hani muziky", e as Error);
}
}

View File

@ -55,11 +55,15 @@ const ifUzRemove = (m: Message) => {
return false;
};
const tovjemamvolepreceroliky = async (roliky: User) => {
const tovjemamvolepreceroliky = async (roliky: User, rictCas?: boolean) => {
const odpoved = await handleSpink("vstavacek", roliky);
if (!odpoved) return "uz jsi vzhuru ty hajzle";
const cas = Number(odpoved.slice(3));
const formatedCas = formatCas(cas);
const zacatek = `dobry rano hajzle ${roliky}`;
if (!rictCas) return zacatek;
let zpr = "";
if (cas >= 57600) zpr = "mas dat more vstavacek uz kdyz vstanes retarde";
else if (cas >= 43200) zpr = "extrémní bídák";
@ -67,7 +71,7 @@ const tovjemamvolepreceroliky = async (roliky: User) => {
else if (cas < 30) zpr = "dobrej mikrospánek debile";
else if (cas < 10800) zpr = "dobrej fake spink debile";
return `dobry rano hajzle ${roliky}\nspal sy ${formatedCas}\n${zpr}`;
return `${zacatek}\nspal sy ${formatedCas}\n${zpr}`;
};
function hmsToCislo(reg: RegExpExecArray | null) {
@ -93,10 +97,10 @@ const exp: Modul = {
vstavacek: {
als: ["vstavcacek", "gm", "unspinkacek"],
run: async mes => {
run: async (mes, arg) => {
if (mes.author.bot) return emouty.sjeta;
return tovjemamvolepreceroliky(mes.author);
return tovjemamvolepreceroliky(mes.author, arg.toLowerCase() != "fejk");
}
},
@ -249,6 +253,7 @@ const exp: Modul = {
return false;
},
// autoSpink handeler
on_userPresenceUpdate: async (bef, aft) => {
if (!bef) return;
const befoff = bef.status == "offline";

View File

@ -7,6 +7,7 @@ import { Modul } from "../utils/types";
import fetch from "node-fetch";
import { adminLog, formatCas, log, nabidni, sendDM } from "../utils/utils";
import { emouty } from "../utils/emotes";
import { readFileSync } from "fs";
const zpravy = new Map<string, Map<string, number[]>>();
const dobaOmezení = 20_000;
@ -82,8 +83,7 @@ const exp: Modul = {
},
lastuptime: () => {
const index = process.argv.length > 3 ? 3 : 2;
const sekundy = Number(process.argv[index]);
const sekundy = Number(process.argv[3]);
if (!sekundy) return "aj forgor 💀";
return `naposled jsem jel ${formatCas(sekundy)}`;
}
@ -131,9 +131,12 @@ const exp: Modul = {
// Nastavení clienta
client = module.exports.client;
// OG onReady
// OG onReady++
log("A jedeš!");
if (process.argv.length >= 4) adminLog(client, "pošel jsem");
if (process.argv[2] == "1") {
const duvod = readFileSync("logs/recent.txt").toString();
adminLog(client, "pošel jsem", duvod);
}
// Server na navrhy
createServer((req, res) => {

View File

@ -3,8 +3,8 @@ import { array, safeParse, string } from "valibot";
import { adminLog, log } from "./utils";
import { Client } from "discord.js";
// Extrémní fekál, jestli má někdo lepsí nápad, sem s ním
export const semMiDejClienta: { client?: Client; } = {};
let client: Client;
export const setClient = (clnt: Client) => client = clnt;
export let lidiCoMajDenimPremium: string[] = [];
@ -21,7 +21,6 @@ function naplanovat() {
}
async function sync() {
log("synchronizace denim-");
const res = await fetch("https://util.deadfish.cz/denim+/subscriptions.json")
.then(r => r.json())
.catch(log);
@ -31,7 +30,7 @@ async function sync() {
if (result.success) {
lidiCoMajDenimPremium = result.output;
} else {
adminLog(semMiDejClienta.client!, "nepovedlo se akutalizovat vlastnitele denim-");
adminLog(client, "nepovedlo se akutalizovat vlastnitele denim-");
}
naplanovat();

View File

@ -68,15 +68,15 @@ export const formatter = new Intl.DateTimeFormat("cs", { day: "numeric", month:
export const ping = /^<@!?\d+>$/;
export function adminLog(client: Client, text: string) {
export function adminLog(client: Client, text: string, err?: string | Error) {
if (process.env.adminChannel) {
const adminChannel = client.channels.cache.get(process.env.adminChannel);
if (adminChannel?.type == ChannelType.GuildText)
adminChannel.send(text);
adminChannel.send(!!err ? `${text}\n\`\`\`${err}\`\`\`` : text);
}
if (process.env.adminID) {
const user = client.users.cache.get(process.env.adminID);
if (user) sendDM(user, text);
if (user) sendDM(user, !!err ? `${text}\n\`\`\`${err}\`\`\`` : text);
}
}

View File

@ -1,26 +1,38 @@
declare -a casy
i=0
posel=0
while true; do
cas=$(date +"%s")
if node . $posel $posledni; then
node . $posel $posledni 2> >(tee logs/aktualni.txt)
kod=$?
posel=0
echo [$(date +"%d.%m. %H:%M:%S")]: vyplo sa to
casDva=$(date +"%s")
posledni=$(($casDva - $cas))
cp logs/aktualni.txt logs/recent.txt
if [[ -s "logs/aktualni.txt" ]]; then
cp logs/aktualni.txt logs/$(date +"%d.%m.-%H-%M-%S-%N").txt
fi
echo exit code byl $kod
if (($kod == 0 )); then
echo stahuju update
git stash
git pull
npm i --omit=dev
live-tsc -s src -d out -f cjs
unset posel
else
kod=$?
echo [$(date +"%d.%m. %H:%M:%S")]: poslo to
echo exit code byl $kod
if (($kod == 69)); then
echo jenom restart
else
posel=1
casy[$i]=$(date +"%s")
posledni=$(($((casy[$i])) - $cas))
if (($i < 3)) || (($((casy[$(($i - 3))])) < $(($((casy[$i])) - 864000)))); then
casy[$i]=$casDva
if (($i < 3)) || (($((casy[$(($i - 3))])) < $(($casDva - 86400)))); then
echo Poslo to dostatecne malo, restartuju
else
echo Poslo to moc, seru na to