A complete Telegram cinema bot in PHP — distribute movies by code, with forced channel subscription, manual-payment premium subscriptions, multi-part series, broadcast scheduler, and a full admin panel. ~2,900 lines, single file, MySQL-backed. Drop on any LAMP server and run.
Copy this prompt and feed it to your favorite AI to remix the project.
You are a senior PHP/Telegram-bot engineer. I have a working cinema
distribution bot in a single PHP file (~2,900 lines) using mysqli +
Telegram Bot API + manual MySQL schema. Source structure:
KEY GLOBALS:
- API_KEY (bot token), $admin (single super-admin Telegram ID)
- $connect (mysqli handle), $setting (loaded from `settings` table)
- $update / $message / $callback / $chat_id / $from_id / $text / $data
TABLES:
- users(user_id, status, date, step, premium, active)
- admins(user_id, opportunities JSON, date)
- movies(code, name, description, file_id, status [all|premium])
- channels(channel_id, url, name, type [default|request|url], status)
- downloads(file_id, date)
- send(message, type, finish, limit, succes, time1..5, button, status)
- pay_methods(name, owner, code)
- zayavka(chat_id, user_id) — pending join requests
- settings(share_save, premium, premium_price)
KEY FUNCTIONS:
- bot($method, $datas) — Telegram API call
- joinchat($id, $file) — enforce subscription, returns true/false
- step($step) — set conversation step for current user
- isPremium($user_id) — boolean check
- user($id) — returns admin permissions JSON or false
- download($file) — record a download
UI:
- Hardcoded Uzbek strings in HTML parse_mode
- Admin reply keyboard: Statistika, Xabar yuborish, Kinolar,
Kanallar, Adminlar, Sozlamalar, Orqaga
- User flow: send code → bot enforces subscription → sends video
YOUR TASK:
[FILL — describe what you want to add/change. Examples:
"Add a 'random movie' command that sends a random non-premium movie
to the user, but only if they're a Telegram Star supporter. Don't
break existing flows."
"Add per-language UI (uz/ru/en). Detect from Telegram language_code,
fall back to uz. Store user's preference in users.lang."
"Replace manual payment methods with Telegram Stars. When user clicks
Sotib olish, send an invoice for 30 stars (≈ premium_price/month).
On successful payment update users.premium = NOW() + 30 days."
"Migrate from mysqli to PDO with prepared statements throughout. Keep
the public API of every function identical."
]
CONSTRAINTS:
1. Output a single self-contained patch — clearly marked sections that
replace specific functions or add new ones, NOT a full rewrite.
2. Preserve admin panel layout exactly (don't move buttons around).
3. New tables must be created with `CREATE TABLE IF NOT EXISTS` so
first-time deploys still work.
4. No new dependencies — pure PHP, no Composer.
5. UI strings stay in Uzbek unless I asked for translation.
6. Wrap risky DB changes in transactions. Use `mysqli_real_escape_string`
for any new user-input concatenation.# Cinema Bot — Telegram movie distribution in PHP
A complete cinema-distribution bot used by hundreds of Uzbek Telegram channels. Users send a movie code, the bot delivers the file. Optional premium tier, forced channel subscription, and a full admin panel. One PHP file, MySQL backend, drop on any LAMP server.
## What it does
123, bot delivers movie #123. Multi-part series supported (sends a numbered listwhen one code has multiple files).
"join request" (private channels), or external URL.
card transfer) — you confirm payments from the admin panel.
configurable delays between batches.
settings. Multi-admin support.
updates and stores them.
chat_join_request## Stack
No frameworks. No Composer. No dependencies. Just cinemabot.php and a database.
## Setup (5 minutes)
### 1. Create a bot
@BotFather on Telegram → /newbot123456:ABC...) ### 2. Database sql CREATE DATABASE cinema CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'cinema'@'localhost' IDENTIFIED BY 'strong-password'; GRANT ALL ON cinema.* TO 'cinema'@'localhost';
Tables are auto-created on first webhook hit (via CREATE TABLE IF NOT EXISTS). No manual schema needed.
### 3. Configure Open cinemabot.php and replace the placeholders at the top: `php define('API_KEY', "YOUR_BOT_TOKEN"); $admin = "YOUR_TELEGRAM_USER_ID"; // get from @userinfobot
define("db_server", "localhost"); define("db_username", "cinema"); define("db_password", "strong-password"); define("db_name", "cinema"); `
### 4. Upload + set webhook Upload cinemabot.php to your server (any shared hosting, VPS, or even free PHP hosts work). Then register the webhook:
https://api.telegram.org/bot<YOUR_TOKEN>/setWebhook?url=https://yoursite.com/cinemabot.php
That's it. Send /start to your bot — you'll see the admin panel.
### 5. Add your first movie
file_id🎬 Kinolar → set the code, name, descriptionNow any user can send the code and get the movie.
## Admin panel — what's where
| Section | What it does |
|---|---|
| 📊 Statistika | Total / active / today's signups / downloads |
| 📨 Xabar yuborish | Broadcast message to all users with delay & retry |
| 🎬 Kinolar | List, add, edit, delete movies; toggle premium-only |
| 🔐 Kanallar | Add forced-subscribe channels (default / request / url types) |
| 👮♀️ Adminlar | Add co-admins with granular permissions |
| ⚙️ Sozlamalar | Toggle premium feature, set price, share-protection, payment methods |
## Customization
The bot's UI is fully Uzbek. Strings are hardcoded — search for bot('sendMessage' to find user-facing text and translate as needed. Same for emoji-prefixed buttons (📊 Statistika, etc.).
For multi-language support, swap hardcoded strings with a translation function: php function t($key, $lang = 'uz') { $translations = [ 'welcome' => ['uz' => 'Xush kelibsiz', 'ru' => 'Добро пожаловать'], // ... ]; return $translations[$key][$lang] ?? $key; }
## Security notes
The included file uses mysqli_query with concatenated variables. Validate all user input before deploying to a public bot — Telegram message text passes through $text, callback data through $data. The codebase trusts these reasonably (everything goes through mysqli_real_escape_string paths or numeric casts), but a security audit is recommended before high-traffic use.
For webhook security, set a secret token: ?secret_token=YOUR_SECRET And verify it in the webhook handler.
## What I learned building this
file_id is the win. Telegram caches every file you've ever uploaded to a bot — store the file_id, send itback, no storage cost.
content in CIS.
integrate the gateway later when you have proven demand.
sweat. Don't over-engineer.
## Roadmap (open contributions)
0 Comments