A telegram bot for searching and auto-saving.
A Python 3 Telegram bot for searching video magnet links. It supports collection and export of records, automatic saving to cloud storage, configurable NSFW filtering, proxy support, and AI-powered natural-language understanding for automatic intent, target, and source detection from user input.
record.jsonnext batch, next page, previous page, save item Nintent, target, source, and explain. Searching: {target}.⏳ Searching .... Search results.✅ Saved successfully.If no AI API is configured, the bot falls back to the original number detection and BT keyword search flow.
…bot.py Main program: config, logging, message handlers, AI flow
ai.py AI intent client using OpenAI-compatible /chat/completions
pikpak.py PikPak official OpenAPI client for login, token refresh, and offline download
database.py Data layer: BotFileDb (JSON records) + BotCacheDb (SQLite cache)
requirements.txt Dependencies
docker-compose.yml One-click deploymentRuntime data is stored under ~/.tg_search_bot/: config.yaml, record.json, cache.db, pikpak_token.json, and log.txt.
Edit ~/.tg_search_bot/config.yaml:
# Required: Telegram chat ID
tg_chat_id:
# Required: Telegram bot token
tg_bot_token:
# Required: use global proxy, 1 = yes, 0 = no
use_proxy:
# Optional: proxy address, required when use_proxy is 1
proxy_addr:
# Required: enable NSFW content, 1 = yes, 0 = no
enable_nsfw: 0
# Optional: PikPak account for auto-saving magnets
pikpak_username:
pikpak_password:
# Optional: AI natural-language search via any OpenAI-compatible API
ai_base_url:
ai_api_key:
ai_model:# Option 1: Docker deployment
docker-compose up -d
# Option 2: run directly (Python 3.9+)
pip install -r requirements.txt
python3 bot.py| Command | Description |
|---|---|
/help |
Show help |
/stars |
View collected performers |
/ids |
View collected numbers |
/record |
Export the records file |
Simply send a movie title, keyword, number, plot summary, performer name, or genre. The AI will understand and search automatically.
BT search results are paginated in groups of 5. You can continue with:
next batch / next page / more — show the next pageprevious page — show the previous pagesave item N or save N — save the N-th magnet to PikPakPython 3.9+ is recommended, preferably with a virtual environment:
git clone https://github.com/akynazh/tg-search-bot.git
cd tg-search-bot
python3 -m venv .venv
source ./.venv/bin/activate
pip3 install -r requirements.txtThanks to JetBrains for supporting this project.
No open issues yet, or sync has not completed.