Add a vault for saving whole forwarded posts
Completes TODO #5. Forwarding a post now asks whether to save it whole or extract its media; sending media directly is unchanged. Built on forwarding rather than copying file_ids. The bot already has the post in its private chat with the owner, so it stores message ids and forwards them back. forwardMessages takes a list and keeps an album intact, which is what made the caption-plus-album case tractable; ids must be strictly ascending, so they are sorted on the way out. - Vault rows live in their own table and every query is scoped to an owner_id, so a guessed id cannot reach someone else's saved post. Nothing in the vault is searchable inline, moderated or federated, and the separate table makes that structural rather than a flag. - Albums arrive as separate messages with no completion signal, so they are buffered by media_group_id behind a 1s debounce and prompt once. - The add path now takes a list of items, so extracting an album stores every piece under one set of keywords instead of asking repeatedly. - /vault searches keywords and the original caption, since the point of a vault is finding something you never got round to tagging. - Retrieval failures are reported: a message id is a pointer into the chat, not a self-contained file_id, so clearing history breaks it. Three near-identical keyword collectors are now one helper. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -65,11 +65,29 @@ Telegram suggests these commands as you type `/`, with a short description besid
|
||||
| `/start` | Start the bot and show usage instructions |
|
||||
| `/menu` | Show the available commands |
|
||||
| `/list` | Show all saved media |
|
||||
| `/vault [search]` | Retrieve a whole post you saved |
|
||||
| `/review` | Review pending submissions one by one (admin only) |
|
||||
| `/edit [search]` | Select a meme and edit its keywords (admin only) |
|
||||
| `/delete <id>` | Remove an entry (get ID from `/list`; admin only) |
|
||||
| `/cancel` | Cancel current add operation |
|
||||
|
||||
### The vault — saving whole posts
|
||||
|
||||
Send the bot media directly and it behaves as it always has: it extracts the media and asks for keywords.
|
||||
|
||||
**Forward** a post to it instead and it asks what you want:
|
||||
|
||||
- **Save whole post** — keeps the post intact in your vault, caption and all. An album stays an album.
|
||||
- **Extract media** — the existing behaviour, adding the media to your searchable library.
|
||||
|
||||
Retrieve saved posts with `/vault [search]`, which matches your keywords and the original caption. Each result has a button to forward it back to you, and one to remove it.
|
||||
|
||||
> **Vault posts only come back inside this bot.** Telegram's inline mode cannot forward an existing message, so `@yourbotusername keyword` does not reach the vault. Retrieve the post in the bot chat, then forward it wherever you want.
|
||||
|
||||
The vault is per-user and private: it is stored separately from the meme library, every lookup is scoped to its owner, and nothing in it is ever moderated or shared.
|
||||
|
||||
Saving stores a pointer to the message in your chat with the bot rather than a copy of the media. If you clear your chat history with the bot, saved posts can no longer be retrieved — the bot tells you when that happens so you can forward them again.
|
||||
|
||||
### Making the bot public
|
||||
|
||||
Set `PUBLIC_MODE=true` to open the bot to anyone who meets a membership requirement, instead of the `ALLOWED_USERS` list:
|
||||
|
||||
Reference in New Issue
Block a user