|
| 1 | +# TorrServer Telegram Bot |
| 2 | + |
| 3 | +[](https://github.com/YouROK/TorrServer/blob/master/LICENSE) |
| 4 | +[](https://github.com/YouROK/TorrServer) |
| 5 | + |
| 6 | +## Introduction |
| 7 | + |
| 8 | +Telegram bot for managing [TorrServer](https://github.com/YouROK/TorrServer) — add torrents, stream, search, and control the server directly from Telegram. |
| 9 | + |
| 10 | +## Features |
| 11 | + |
| 12 | +- Torrent management — add, remove, drop, list via magnet, hash, or `torrs://` |
| 13 | +- Export & import — magnets list; import multiple from text |
| 14 | +- Streaming — playback links, M3U playlists, preload |
| 15 | +- Search — RuTor and Torznab with one-click add |
| 16 | +- Inline mode — `@botname` in any chat: list torrents or search |
| 17 | +- Status & snake — real-time status, cache visualization |
| 18 | +- File operations — browse files, download to Telegram |
| 19 | +- FFprobe — media metadata via `/ffp` |
| 20 | +- Localization — Russian and English |
| 21 | +- Admin — shutdown, settings, presets (whitelist users only) |
| 22 | + |
| 23 | +## Getting Started |
| 24 | + |
| 25 | +### Enable the Bot |
| 26 | + |
| 27 | +Start TorrServer with a Telegram bot token: |
| 28 | + |
| 29 | +```bash |
| 30 | +TorrServer --tg YOUR_BOT_TOKEN |
| 31 | +``` |
| 32 | + |
| 33 | +Or use `-T`: |
| 34 | + |
| 35 | +```bash |
| 36 | +TorrServer -T YOUR_BOT_TOKEN |
| 37 | +``` |
| 38 | + |
| 39 | +Create a bot via [@BotFather](https://t.me/BotFather) to get the token. |
| 40 | + |
| 41 | +### Configuration |
| 42 | + |
| 43 | +Config file `tg.cfg` (JSON) in the TorrServer data directory: |
| 44 | + |
| 45 | +| Field | Description | |
| 46 | +|------------|-------------| |
| 47 | +| `HostTG` | Telegram API URL (default: `https://api.telegram.org`) | |
| 48 | +| `HostWeb` | Base URL for stream links (auto-detected if empty) | |
| 49 | +| `WhiteIds` | Allowed user IDs (empty = allow all) | |
| 50 | +| `BlackIds` | Blocked user IDs | |
| 51 | + |
| 52 | +Example: |
| 53 | + |
| 54 | +```json |
| 55 | +{ |
| 56 | + "HostTG": "https://api.telegram.org", |
| 57 | + "HostWeb": "http://192.168.1.100:8090", |
| 58 | + "WhiteIds": [123456789], |
| 59 | + "BlackIds": [] |
| 60 | +} |
| 61 | +``` |
| 62 | + |
| 63 | +## Commands |
| 64 | + |
| 65 | +### Core |
| 66 | + |
| 67 | +| Command | Description | |
| 68 | +|---------|-------------| |
| 69 | +| `/help`, `/start`, `/id` | Help and user ID | |
| 70 | +| `/list [compact]` | List torrents with buttons | |
| 71 | +| `/add <link>` | Add torrent (magnet, hash, torrs://) | |
| 72 | +| `/clear` | Remove all (with confirmation) | |
| 73 | +| `/hash [N]` | Show info hashes | |
| 74 | + |
| 75 | +### Management |
| 76 | + |
| 77 | +| Command | Description | |
| 78 | +|---------|-------------| |
| 79 | +| `/remove <hash\|N>` | Remove torrent | |
| 80 | +| `/drop <hash\|N>` | Disconnect (keep in DB) | |
| 81 | +| `/set <hash\|N> <title>` | Set title | |
| 82 | +| `/status [hash\|N]` | Status with refresh/stop | |
| 83 | +| `/cache <hash\|N>` | Cache stats | |
| 84 | +| `/preload <hash\|N> <index>` | Preload file | |
| 85 | + |
| 86 | +### Links & Playback |
| 87 | + |
| 88 | +| Command | Description | |
| 89 | +|---------|-------------| |
| 90 | +| `/link`, `/play` | Stream URL | |
| 91 | +| `/m3u`, `/m3uall` | M3U playlist | |
| 92 | + |
| 93 | +### Search |
| 94 | + |
| 95 | +| Command | Description | |
| 96 | +|---------|-------------| |
| 97 | +| `/search <query>` | RuTor + Torznab (all sources) | |
| 98 | +| `/rutor <query>` | RuTor only | |
| 99 | +| `/torznab <query> [index]` | Torznab indexers | |
| 100 | + |
| 101 | +### Other |
| 102 | + |
| 103 | +| Command | Description | |
| 104 | +|---------|-------------| |
| 105 | +| `/export`, `/import` | Export/import magnets | |
| 106 | +| `/categories` | List categories | |
| 107 | +| `/server`, `/stats`, `/stat` | Server info | |
| 108 | +| `/viewed` | Viewed files | |
| 109 | +| `/ffp <hash\|N> <id> [json]` | FFprobe metadata | |
| 110 | +| `/speedtest [size]` | Download test (1–100 MB) | |
| 111 | +| `/snake [hash\|N] [cols] [rows]` | Cache visualization | |
| 112 | +| `/lang [RU\|EN]` | Language | |
| 113 | + |
| 114 | +### Admin Only |
| 115 | + |
| 116 | +| Command | Description | |
| 117 | +|---------|-------------| |
| 118 | +| `/shutdown` | Shut down server | |
| 119 | +| `/settings` | Interactive settings menu (sub-pages: Search, Network, Other, Cache, Paths, Storage) | |
| 120 | +| `/preset <name>` | Apply named preset: `performance`, `storage`, `streaming`, `low`, `default` | |
| 121 | +| `/preset <key> <value> ...` | Apply key-value pairs: `cache 256`, `preload 50`, `conn 100`, etc. | |
| 122 | + |
| 123 | +**Preset examples:** |
| 124 | +- `/preset performance` — max cache, high preload, no limits |
| 125 | +- `/preset cache 256 preload 50` — set cache 256 MB and preload 50% |
| 126 | +- `/preset cache 512 conn 100 down 0 up 0` — multiple values |
| 127 | + |
| 128 | +**Preset keys:** `cache`, `preload`, `readahead`, `conn`, `timeout`, `port`, `down`, `up`, `retr`, `responsive`, `cachedrop` |
| 129 | + |
| 130 | +## Inline Mode |
| 131 | + |
| 132 | +Type `@YourBotName` in any chat: |
| 133 | + |
| 134 | +- **Empty, "list", or "play"** — torrents with play links |
| 135 | +- **2+ characters** — search RuTor + Torznab |
| 136 | + |
| 137 | +## Text Input |
| 138 | + |
| 139 | +Paste as plain message to add torrent: |
| 140 | + |
| 141 | +- `magnet:?xt=urn:btih:...` |
| 142 | +- `torrs://...` |
| 143 | +- 40-char info hash |
| 144 | + |
| 145 | +Reply to file list with `2-12` to download files 2–12 to Telegram. |
| 146 | + |
| 147 | +## Security |
| 148 | + |
| 149 | +- **Whitelist** — restrict to specific user IDs |
| 150 | +- **Blacklist** — block user IDs |
| 151 | +- **Admin** — when whitelist is used, admin = whitelisted users |
| 152 | +- **Settings** — sensitive values masked in `/settings` |
| 153 | + |
| 154 | +## Dependencies |
| 155 | + |
| 156 | +- [telebot v4](https://gopkg.in/telebot.v4) — Telegram Bot API |
| 157 | +- [go-humanize](https://github.com/dustin/go-humanize) |
| 158 | +- [go-ffprobe](https://gopkg.in/vansante/go-ffprobe.v2) |
0 commit comments