feat(userbot,api,frontend): file links, media downloads, story hold-pause, drop scheduled dupes

This commit is contained in:
hh committed 2026-08-13 03:17:36 +02:00
1 parent 683b9a31a3
commit 3e08698b62
38 files changed
+2889 -134

No files matched your search

+15 -15
View File
@@ -1,27 +1,27 @@
const MEDIA_KIND_LABELS: Record<string, string> = {
photo: "Photo",
video: "Video",
photo: "Фото",
video: "Видео",
animation: "GIF",
gif: "GIF",
voice: "Voice message",
audio: "Audio",
video_note: "Video message",
sticker: "Sticker",
document: "File",
contact: "Contact",
location: "Location",
venue: "Location",
poll: "Poll",
dice: "Dice",
game: "Game",
story: "Story",
voice: "Голосовое",
audio: "Аудио",
video_note: "Кружок",
sticker: "Стикер",
document: "Файл",
contact: "Контакт",
location: "Геопозиция",
venue: "Геопозиция",
poll: "Опрос",
dice: "Кубик",
game: "Игра",
story: "Сторис",
};
export function mediaKindLabel(kind: string | null): string | null {
if (!kind) {
return null;
}
return MEDIA_KIND_LABELS[kind] ?? "Media";
return MEDIA_KIND_LABELS[kind] ?? "Медиа";
}
const BYTE_UNITS = ["B", "KB", "MB", "GB"];
+55
View File
@@ -0,0 +1,55 @@
import type { FileShare } from "$lib/api/types";
import { formatFull } from "$lib/format/datetime";
const TEEN_START = 11;
const TEEN_END = 14;
const FEW_END = 4;
export function plural(
count: number,
one: string,
few: string,
many: string
): string {
const tail = count % 100;
if (tail >= TEEN_START && tail <= TEEN_END) {
return many;
}
const last = count % 10;
if (last === 1) {
return one;
}
if (last >= 2 && last <= FEW_END) {
return few;
}
return many;
}
export function formatDownloads(share: FileShare): string {
const word = plural(
share.download_count,
"скачивание",
"скачивания",
"скачиваний"
);
if (share.max_downloads === null) {
return `${share.download_count} ${word}`;
}
return `${share.download_count} из ${share.max_downloads}`;
}
export function formatExpiry(share: FileShare): string {
if (share.revoked_at) {
return "отозвана";
}
if (!share.expires_at) {
return "бессрочно";
}
const expires = Date.parse(share.expires_at);
const prefix = expires <= Date.now() ? "истекла" : "до";
return `${prefix} ${formatFull(share.expires_at)}`;
}
export function formatShareLimits(share: FileShare): string {
return `${formatDownloads(share)} · ${formatExpiry(share)}`;
}