DEV Community

Andrii Sheptytskyi
Andrii Sheptytskyi

Posted on

I Got Tired of Manually Managing My Paid Telegram Channel, So I Built a Bot

Last month I was spending hours every week doing the same boring tasks: checking who paid, generating invite links, removing people whose subscriptions expired. Classic manual work that screams "automate me."

So I did.

The Problem

Running a paid Telegram channel sounds easy until you actually do it. Here's what my daily routine looked like:

  • Someone pays → I manually check → I manually create an invite link → I send it
  • Someone's subscription expires → I manually check a spreadsheet → I manually kick them
  • Someone asks "did my payment go through?" → I dig through payment history

Multiply this by 50+ subscribers and you've got yourself a part-time job you didn't sign up for.

What I Built

A Python bot that handles everything automatically. User pays with Telegram Stars → bot verifies → bot sends invite link → done. No human needed.

When subscription expires, the bot kicks them. When it's about to expire, the bot sends a reminder. When someone uses a referral link, both people get bonus days.

The whole thing runs on a $5 VPS and I haven't touched it in weeks.

The Technical Stuff

I used aiogram 3 because it's async and doesn't suck. SQLite for storage because I'm not running a bank here. Telegram Stars for payments because it's built into Telegram and I don't need to deal with Stripe integration.

The bot structure is dead simple:

  • bot.py — handles messages and payments
  • database.py — stores users, subscriptions, payments
  • config.py — prices, messages, tokens

A background task runs every hour to check for expired subscriptions and kick people. Another one sends reminders before expiry.

Features That Actually Matter

Telegram Stars payment — Users buy Stars in the app, pay your bot. You get the money. No third-party processors, no KYC headaches.

Auto invite links — After payment, bot creates a one-time invite link. User clicks, they're in. Link expires after use.

Auto-kick — Subscription ends, user gets removed. No awkward manual removals.

Referral system — Users share their link, get bonus days when friends sign up. Free marketing.

Promo codes — Create discount codes for launches, holidays, whatever.

Was It Worth It?

I spent a weekend building this. It now saves me several hours every week and runs completely hands-off. So yeah, worth it.

If you're running a paid channel and still doing things manually — stop. Automate it or you'll burn out.


I packaged this into a ready-to-deploy solution. Full source code, documentation, everything you need to get it running.

Get it here if you want to skip the building part.

Top comments (2)

Collapse
 
haskelldev profile image
Haskell Thurber •

This resonates so much! I've been through exactly the same automation journey with my Telegram Mini App.

The Stars payment flow you described is spot on — that one-tap experience is what makes Telegram payments actually work. No redirect, no card form, just tap and done. I had a similar "aha moment" when I integrated Stars into WhisprMe (anonymous messaging app). The conversion rate vs. any external payment was night and day.

Your referral system approach is interesting too. We built something similar — users earn premium features for inviting friends. The trick we found: showing the referral count publicly (via a leaderboard) creates a competitive loop that drives organic sharing.

A few things I learned the hard way that might save you time:

  1. Background task scheduling — instead of checking every hour, we use pg_cron for database-level scheduling. More reliable than a Python loop if the bot crashes.
  2. Idempotent payments — Telegram can sometimes send duplicate successful_payment events. Make sure your handler checks for already-processed transactions.
  3. Expiry grace period — we give 24h grace before kicking. Reduces angry users who forgot to renew by 1 day.

How many active subscribers are you managing now?

Collapse
 
btc_x_coder_6527470b66642 profile image
btc_x_coder •

Nice build — the auto invite link + auto kick flow is exactly right. I went down a similar path and ended up shipping it as a product (Paywall.Tel), so here's my honest take after living in this problem space:

The one thing I'd rethink is Stars as the payment rail. The in-app UX is great, but the money lands in Telegram's balance — you have to cash out through their payout process, and after the Stars→USD conversion the effective take is noticeably less than face value. For a paid channel, the payment rail is the business model.

That's why we went with USDT on Solana: each payment is auto-forwarded to the channel owner's own wallet the moment it lands (no platform balance, no withdrawal step), fees are ~$0.01 on-chain, and there's no processor in the middle. Trade-off, to be honest: your audience needs to be comfortable buying crypto — though buying USDT on an exchange and sending it to a payment address works fine without a personal wallet.

Two design differences worth stealing if you iterate: trial before payment (buyers join the private channel and see the full content before paying — kills refund drama) and permanent access on one-time payment instead of subscription expiry management (no more cron jobs for kicking people, which is honestly the ugliest part of the stack).