0a8c81db90
Completes TODO #3. Submissions are gated behind ACCEPT_SUBMISSIONS, which defaults to off: is_allowed() treats everyone as allowed when ALLOWED_USERS is empty, so opening submissions implicitly would have accepted media from anyone who found the bot. - Schema v3 adds status, reviewed_by and reviewed_at. Existing rows default to approved, so upgrading changes nothing for a running bot. - Search, /list and counts only return approved items; callers that need everything pass status=None. - /review shows the oldest pending item with approve, reject, fix keywords and stop. No cursor is stored anywhere: each action just asks for the next pending item, which is what lets a moderator stop and resume later, and lets several moderators share one queue. - set_status only updates rows still pending, so if two moderators open the same item the first decision wins and the second is told so. - A failed send no longer wedges the queue; the item's details are shown anyway so it can still be rejected. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
89 lines
3.1 KiB
Markdown
89 lines
3.1 KiB
Markdown
# Memes Bot
|
|
|
|
A personal Telegram inline bot to store and search media (photos, GIFs, videos, voice, music, stickers, files) by keywords.
|
|
|
|
[فارسی](README.fa.md)
|
|
|
|
---
|
|
|
|
### Requirements
|
|
|
|
- A server with [Docker](https://docs.docker.com/engine/install/) installed
|
|
- A Telegram bot token from [@BotFather](https://t.me/BotFather)
|
|
|
|
### Setup
|
|
|
|
**1. Create the bot in BotFather**
|
|
- `/newbot` → get your token
|
|
- `/setinline` → enable inline mode, set a placeholder (e.g. `Search memes...`)
|
|
|
|
**2. Find your Telegram user ID**
|
|
|
|
You need your numeric Telegram user ID to whitelist yourself.
|
|
|
|
- **Easiest:** forward any message to [@userinfobot](https://t.me/userinfobot) — it replies with your ID
|
|
- **Alternative:** open Telegram Web, click your profile, the number in the URL is your ID
|
|
- **For multiple users:** repeat for each person and separate IDs with commas
|
|
|
|
**3. Clone and configure**
|
|
|
|
```bash
|
|
git clone https://git.goyban.com/goyban/memes_bot
|
|
cd memes_bot
|
|
cp .env.example .env
|
|
```
|
|
|
|
Edit `.env`:
|
|
|
|
```env
|
|
BOT_TOKEN=your_telegram_bot_token_here
|
|
ALLOWED_USERS=123456789,987654321
|
|
```
|
|
|
|
**4. Run**
|
|
|
|
```bash
|
|
docker compose up -d --build
|
|
```
|
|
|
|
The database will be saved in `./bot_db/media.db`.
|
|
|
|
### Usage
|
|
|
|
**Adding media** — send the bot a photo, GIF, video, voice message, music file, sticker, or any document, then type keywords when prompted (comma-separated or one per message), then `/done`.
|
|
|
|
Round video messages are stored as regular videos: Telegram has no inline result type for video notes, so keeping them as video is what makes them searchable.
|
|
|
|
**Searching inline** — in any chat type `@yourbotusername keyword` to search and send.
|
|
|
|
Telegram suggests these commands as you type `/`, with a short description beside each suggestion.
|
|
|
|
**Commands**
|
|
|
|
| Command | Description |
|
|
|---|---|
|
|
| `/start` | Start the bot and show usage instructions |
|
|
| `/menu` | Show the available commands |
|
|
| `/list` | Show all saved media |
|
|
| `/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 |
|
|
|
|
### Accepting submissions
|
|
|
|
Set `ACCEPT_SUBMISSIONS=true` in `.env` to let non-admin users send media too. Their submissions are stored but stay invisible — they don't appear in inline search or `/list` until a moderator approves them. Admins' own media is still saved directly.
|
|
|
|
Run `/review` to work through the queue. Each item is shown with its keywords and four buttons: approve, reject, fix keywords, or stop.
|
|
|
|
The queue keeps no cursor. `/review` always fetches the oldest pending item, so you can stop after three and come back tomorrow, and several moderators can review at the same time without stepping on each other — if two open the same item, the first decision wins and the second is told it was already handled.
|
|
|
|
> **Leave this off unless you mean it.** With `ALLOWED_USERS` empty, everyone is an allowed user, so turning submissions on would accept media from anyone who finds the bot.
|
|
|
|
### Moving to another server
|
|
|
|
The only files you need to transfer are:
|
|
|
|
- `.env`
|
|
- `bot_db/media.db`
|