Compare commits
10 Commits
0a786106bd
...
fda8571cbe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fda8571cbe | ||
|
|
88022bd15f | ||
|
|
ff3d928a41 | ||
|
|
b09cf48709 | ||
|
|
d78ff668fe | ||
|
|
567fe18bac | ||
|
|
77812f7a43 | ||
|
|
29aefdd3da | ||
|
|
6d39dc89b2 | ||
|
|
61f67a86f0 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@ res/customKomandy.json
|
|||||||
res/customAliasy.json
|
res/customAliasy.json
|
||||||
zaznamy.dlog
|
zaznamy.dlog
|
||||||
zvuky/priVstupu
|
zvuky/priVstupu
|
||||||
|
logs
|
||||||
|
|||||||
1343
package-lock.json
generated
1343
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "denim_3001",
|
"name": "denim_3001",
|
||||||
"version": "3001.54.0",
|
"version": "3001.54.4",
|
||||||
"description": "Toto je velmi kvalitní bot.",
|
"description": "Toto je velmi kvalitní bot.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "https://github.com/Histmy/Denim-Bot/"
|
"url": "https://github.com/Histmy/Denim-Bot/"
|
||||||
@ -15,7 +15,7 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/voice": "^0.16.0",
|
"@discordjs/voice": "^0.16.0",
|
||||||
"discord.js": "^14.11.0",
|
"discord.js": "^14.13.0",
|
||||||
"js-levenshtein": "^1.1.6",
|
"js-levenshtein": "^1.1.6",
|
||||||
"mysql": "^2.18.1",
|
"mysql": "^2.18.1",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
@ -23,13 +23,13 @@
|
|||||||
"play-dl": "^1.9.6",
|
"play-dl": "^1.9.6",
|
||||||
"tiny-typed-emitter": "^2.1.0",
|
"tiny-typed-emitter": "^2.1.0",
|
||||||
"tweetnacl": "^1.0.3",
|
"tweetnacl": "^1.0.3",
|
||||||
"valibot": "^0.13.1"
|
"valibot": "^0.14.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.3",
|
"@types/jest": "^29.5.4",
|
||||||
"@types/js-levenshtein": "^1.1.1",
|
"@types/js-levenshtein": "^1.1.1",
|
||||||
"@types/mysql": "^2.15.21",
|
"@types/mysql": "^2.15.21",
|
||||||
"@types/node-fetch": "^2.6.4",
|
"@types/node-fetch": "^2.6.4",
|
||||||
"jest": "^29.6.1"
|
"jest": "^29.6.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 { adminLog, formatCas, oddiakritikovat, log, rand, prefix, nabidni } from "./utils/utils.js";
|
||||||
import levenshtein from "js-levenshtein";
|
import levenshtein from "js-levenshtein";
|
||||||
import { emouty } from "./utils/emotes";
|
import { emouty } from "./utils/emotes";
|
||||||
import { lidiCoMajDenimPremium } from "./utils/denim-Spravce";
|
import { lidiCoMajDenimPremium, setClient } from "./utils/denim-Spravce";
|
||||||
|
|
||||||
const ints = GatewayIntentBits;
|
const ints = GatewayIntentBits;
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
@ -21,6 +21,7 @@ const helpServer: HelpServer = require("./utils/helpServer");
|
|||||||
|
|
||||||
client.komandy = {};
|
client.komandy = {};
|
||||||
client.aliasy = {};
|
client.aliasy = {};
|
||||||
|
setClient(client);
|
||||||
|
|
||||||
function getFirstArg(fn: KomandRaw["run"]) {
|
function getFirstArg(fn: KomandRaw["run"]) {
|
||||||
if (typeof fn != "function") return;
|
if (typeof fn != "function") return;
|
||||||
@ -38,7 +39,7 @@ const runEvent = (name: string, args: unknown[]) => {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (process.env.dieOnError) throw e;
|
if (process.env.dieOnError) throw e;
|
||||||
log("error pri spusteni super listeneru", e as Error);
|
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) {
|
} catch (e) {
|
||||||
if (process.env.dieOnError) throw e;
|
if (process.env.dieOnError) throw e;
|
||||||
log("error pri spousteni eventu", e as Error);
|
log("error pri spousteni eventu", e as Error);
|
||||||
adminLog(client, "error pri eventu");
|
adminLog(client, "error pri eventu", e as Error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -281,7 +281,7 @@ const exp: Modul = {
|
|||||||
fields: [{ name: zacatekNazvu, value: `• ${stranky[0].join("\n• ")}` }]
|
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})`;
|
embed.fields![0].name += ` (1/${stranky.length})`;
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,22 @@
|
|||||||
import { getVoiceConnection } from "@discordjs/voice";
|
import { getVoiceConnection } from "@discordjs/voice";
|
||||||
import { Modul } from "../utils/types";
|
import { Modul } from "../utils/types";
|
||||||
import { rmSync, readdirSync, writeFileSync } from "fs";
|
import { renameSync, rmSync, readdirSync, writeFileSync } from "fs";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { Priority, novejPlay } from "../utils/voice";
|
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 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 kmenovaCesta = join(__dirname, `../../zvuky/priVstupu`);
|
||||||
const formaty = ["mp3", "wav", "ogg"];
|
const formaty = ["mp3", "wav", "ogg"];
|
||||||
|
|
||||||
|
function vymaz(path: string) {
|
||||||
|
try {
|
||||||
|
rmSync(path);
|
||||||
|
} catch { }
|
||||||
|
}
|
||||||
|
|
||||||
const exp: Modul = {
|
const exp: Modul = {
|
||||||
more_komandy: {
|
more_komandy: {
|
||||||
|
|
||||||
@ -23,19 +29,42 @@ const exp: Modul = {
|
|||||||
if (!soubor) return "tak pico ael na co";
|
if (!soubor) return "tak pico ael na co";
|
||||||
|
|
||||||
if (!formaty.includes(soubor.name.slice(-3))) return "tuten format nechcy";
|
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}`;
|
// Stahnout dočasně
|
||||||
for (const format of formaty) {
|
const typ = soubor.name.slice(-3);
|
||||||
try {
|
const docasnaCesta = `${kmenovaCesta}/temp${Math.round(Math.random() * 1000)}.${typ}`;
|
||||||
rmSync(`${zaklad}.${format}`);
|
|
||||||
} catch { }
|
|
||||||
}
|
|
||||||
|
|
||||||
const odpoved = await fetch(soubor.url).then(r => r.arrayBuffer());
|
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");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -35,7 +35,7 @@ async function playNext(guildId: string, seek?: number) {
|
|||||||
|
|
||||||
log(e);
|
log(e);
|
||||||
const client: Client = module.exports.client;
|
const client: Client = module.exports.client;
|
||||||
adminLog(client, "error v hani muziky");
|
adminLog(client, "error v hani muziky", e as Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -55,11 +55,15 @@ const ifUzRemove = (m: Message) => {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const tovjemamvolepreceroliky = async (roliky: User) => {
|
const tovjemamvolepreceroliky = async (roliky: User, rictCas?: boolean) => {
|
||||||
const odpoved = await handleSpink("vstavacek", roliky);
|
const odpoved = await handleSpink("vstavacek", roliky);
|
||||||
if (!odpoved) return "uz jsi vzhuru ty hajzle";
|
if (!odpoved) return "uz jsi vzhuru ty hajzle";
|
||||||
const cas = Number(odpoved.slice(3));
|
const cas = Number(odpoved.slice(3));
|
||||||
const formatedCas = formatCas(cas);
|
const formatedCas = formatCas(cas);
|
||||||
|
|
||||||
|
const zacatek = `dobry rano hajzle ${roliky}`;
|
||||||
|
if (!rictCas) return zacatek;
|
||||||
|
|
||||||
let zpr = "";
|
let zpr = "";
|
||||||
if (cas >= 57600) zpr = "mas dat more vstavacek uz kdyz vstanes retarde";
|
if (cas >= 57600) zpr = "mas dat more vstavacek uz kdyz vstanes retarde";
|
||||||
else if (cas >= 43200) zpr = "extrémní bídák";
|
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 < 30) zpr = "dobrej mikrospánek debile";
|
||||||
else if (cas < 10800) zpr = "dobrej fake spink 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) {
|
function hmsToCislo(reg: RegExpExecArray | null) {
|
||||||
@ -93,10 +97,10 @@ const exp: Modul = {
|
|||||||
|
|
||||||
vstavacek: {
|
vstavacek: {
|
||||||
als: ["vstavcacek", "gm", "unspinkacek"],
|
als: ["vstavcacek", "gm", "unspinkacek"],
|
||||||
run: async mes => {
|
run: async (mes, arg) => {
|
||||||
if (mes.author.bot) return emouty.sjeta;
|
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;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// autoSpink handeler
|
||||||
on_userPresenceUpdate: async (bef, aft) => {
|
on_userPresenceUpdate: async (bef, aft) => {
|
||||||
if (!bef) return;
|
if (!bef) return;
|
||||||
const befoff = bef.status == "offline";
|
const befoff = bef.status == "offline";
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import { Modul } from "../utils/types";
|
|||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import { adminLog, formatCas, log, nabidni, sendDM } from "../utils/utils";
|
import { adminLog, formatCas, log, nabidni, sendDM } from "../utils/utils";
|
||||||
import { emouty } from "../utils/emotes";
|
import { emouty } from "../utils/emotes";
|
||||||
|
import { readFileSync } from "fs";
|
||||||
|
|
||||||
const zpravy = new Map<string, Map<string, number[]>>();
|
const zpravy = new Map<string, Map<string, number[]>>();
|
||||||
const dobaOmezení = 20_000;
|
const dobaOmezení = 20_000;
|
||||||
@ -82,8 +83,7 @@ const exp: Modul = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
lastuptime: () => {
|
lastuptime: () => {
|
||||||
const index = process.argv.length > 3 ? 3 : 2;
|
const sekundy = Number(process.argv[3]);
|
||||||
const sekundy = Number(process.argv[index]);
|
|
||||||
if (!sekundy) return "aj forgor 💀";
|
if (!sekundy) return "aj forgor 💀";
|
||||||
return `naposled jsem jel ${formatCas(sekundy)}`;
|
return `naposled jsem jel ${formatCas(sekundy)}`;
|
||||||
}
|
}
|
||||||
@ -131,9 +131,12 @@ const exp: Modul = {
|
|||||||
// Nastavení clienta
|
// Nastavení clienta
|
||||||
client = module.exports.client;
|
client = module.exports.client;
|
||||||
|
|
||||||
// OG onReady
|
// OG onReady++
|
||||||
log("A jedeš!");
|
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
|
// Server na navrhy
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
|
|||||||
@ -3,8 +3,8 @@ import { array, safeParse, string } from "valibot";
|
|||||||
import { adminLog, log } from "./utils";
|
import { adminLog, log } from "./utils";
|
||||||
import { Client } from "discord.js";
|
import { Client } from "discord.js";
|
||||||
|
|
||||||
// Extrémní fekál, jestli má někdo lepsí nápad, sem s ním
|
let client: Client;
|
||||||
export const semMiDejClienta: { client?: Client; } = {};
|
export const setClient = (clnt: Client) => client = clnt;
|
||||||
|
|
||||||
export let lidiCoMajDenimPremium: string[] = [];
|
export let lidiCoMajDenimPremium: string[] = [];
|
||||||
|
|
||||||
@ -21,7 +21,6 @@ function naplanovat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function sync() {
|
async function sync() {
|
||||||
log("synchronizace denim-");
|
|
||||||
const res = await fetch("https://util.deadfish.cz/denim+/subscriptions.json")
|
const res = await fetch("https://util.deadfish.cz/denim+/subscriptions.json")
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.catch(log);
|
.catch(log);
|
||||||
@ -31,7 +30,7 @@ async function sync() {
|
|||||||
if (result.success) {
|
if (result.success) {
|
||||||
lidiCoMajDenimPremium = result.output;
|
lidiCoMajDenimPremium = result.output;
|
||||||
} else {
|
} else {
|
||||||
adminLog(semMiDejClienta.client!, "nepovedlo se akutalizovat vlastnitele denim-");
|
adminLog(client, "nepovedlo se akutalizovat vlastnitele denim-");
|
||||||
}
|
}
|
||||||
|
|
||||||
naplanovat();
|
naplanovat();
|
||||||
|
|||||||
@ -68,15 +68,15 @@ export const formatter = new Intl.DateTimeFormat("cs", { day: "numeric", month:
|
|||||||
|
|
||||||
export const ping = /^<@!?\d+>$/;
|
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) {
|
if (process.env.adminChannel) {
|
||||||
const adminChannel = client.channels.cache.get(process.env.adminChannel);
|
const adminChannel = client.channels.cache.get(process.env.adminChannel);
|
||||||
if (adminChannel?.type == ChannelType.GuildText)
|
if (adminChannel?.type == ChannelType.GuildText)
|
||||||
adminChannel.send(text);
|
adminChannel.send(!!err ? `${text}\n\`\`\`${err}\`\`\`` : text);
|
||||||
}
|
}
|
||||||
if (process.env.adminID) {
|
if (process.env.adminID) {
|
||||||
const user = client.users.cache.get(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
30
start.sh
30
start.sh
@ -1,26 +1,38 @@
|
|||||||
declare -a casy
|
declare -a casy
|
||||||
i=0
|
i=0
|
||||||
|
posel=0
|
||||||
while true; do
|
while true; do
|
||||||
cas=$(date +"%s")
|
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
|
echo stahuju update
|
||||||
git stash
|
git stash
|
||||||
git pull
|
git pull
|
||||||
npm i --omit=dev
|
npm i --omit=dev
|
||||||
live-tsc -s src -d out -f cjs
|
live-tsc -s src -d out -f cjs
|
||||||
unset posel
|
|
||||||
else
|
else
|
||||||
kod=$?
|
|
||||||
echo [$(date +"%d.%m. %H:%M:%S")]: poslo to
|
|
||||||
echo exit code byl $kod
|
|
||||||
if (($kod == 69)); then
|
if (($kod == 69)); then
|
||||||
echo jenom restart
|
echo jenom restart
|
||||||
else
|
else
|
||||||
posel=1
|
posel=1
|
||||||
casy[$i]=$(date +"%s")
|
casy[$i]=$casDva
|
||||||
posledni=$(($((casy[$i])) - $cas))
|
if (($i < 3)) || (($((casy[$(($i - 3))])) < $(($casDva - 86400)))); then
|
||||||
|
|
||||||
if (($i < 3)) || (($((casy[$(($i - 3))])) < $(($((casy[$i])) - 864000)))); then
|
|
||||||
echo Poslo to dostatecne malo, restartuju
|
echo Poslo to dostatecne malo, restartuju
|
||||||
else
|
else
|
||||||
echo Poslo to moc, seru na to
|
echo Poslo to moc, seru na to
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user