Support audio, documents, stickers and video notes

Completes TODO #6. The bot accepted photo, animation, video, voice and
sticker; music files, documents and round videos were silently dropped.

- Replace the five near-identical media handlers with one dispatch table.
  Animations are matched before documents because Telegram populates
  both fields for a GIF, so the old ordering would have filed every GIF
  as a document once document support existed.
- Store video notes as "video". Telegram has no cached inline result for
  video notes, so this is what keeps round videos searchable; it costs
  the round presentation on playback.
- Build inline results from a table keyed by media_type, and cover audio
  and document. A test asserts every storable type has a builder, so a
  new media type cannot be added without a way to return it.
- Reuse one MEDIA_FILTER for both the idle and mid-keyword handlers;
  the second list had already drifted from the first.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
goyban
2026-09-01 21:25:11 +00:00
parent b55cee1650
commit efc2be5f8a
6 changed files with 166 additions and 60 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
# Memes Bot
ربات شخصی تلگرام برای ذخیره و جستجوی میم (عکس، گیف، ویدیو، صدا) با کلیدواژه.
ربات شخصی تلگرام برای ذخیره و جستجوی میم (عکس، گیف، ویدیو، صدا، موزیک، استیکر، فایل) با کلیدواژه.
[English](README.md)
@@ -50,7 +50,7 @@ docker compose up -d --build
### نحوه استفاده
**افزودن میم** — یک عکس، گیف، ویدیو یا صدا برای ربات بفرستید. ربات از شما کلیدواژه می‌خواهد. کلیدواژه‌ها را یکی‌یکی یا با کاما جدا بفرستید، سپس `/done` بزنید.
**افزودن میم** — یک عکس، گیف، ویدیو، صدا، موزیک، استیکر یا هر فایلی برای ربات بفرستید. ربات از شما کلیدواژه می‌خواهد. کلیدواژه‌ها را یکی‌یکی یا با کاما جدا بفرستید، سپس `/done` بزنید.
**جستجوی اینلاین** — در هر چتی بنویسید `@نام_ربات کلیدواژه` تا نتایج نمایش داده شود.