Building a Telegram Proxy Status Bot (Tutorial)
Build a small Python bot that monitors TGFast servers and reports their status. Full code included.
What we are building
A small Telegram bot that you can add to a group chat. When users send /status, it replies with the live ping and uptime of the TGFast fleet. The bot uses Python 3.11+, the python-telegram-bot library, and connects to Telegram via TGFast itself (so it works even from restricted regions).
Prerequisites
Python 3.11+, a Telegram bot token (get one from @BotFather), and a small VPS or local computer. The bot does about 10 KB/s of traffic so it runs comfortably on a Raspberry Pi Zero 2W.
Get a free TGFast proxy
Browse the live country grid on the home page and tap any card to connect Telegram in one second — no signup, no logs.
Open the fleetInstall dependencies
pip install python-telegram-bot pythonpingThis installs the bot framework and a pure-Python ping library that does not need root.Bot code
import asyncio
from telegram.ext import Application, CommandHandler
from pythonping import ping
SERVERS = [
("a TGFast proxy", "your TGFast card hostname"),
("a higher-throughput TGFast proxy", "your TGFast card hostname"),
("a TGFast proxy", "your TGFast card hostname"),
("an APAC TGFast proxy", "your TGFast card hostname"),
("a TGFast proxy", "your TGFast card hostname")
]
async def status(update, context):
lines = ["TGFast Status:"]
for name, host in SERVERS:
try:
r = ping(host, count=2, timeout=2)
lines.append(f"{name}: OK {int(r.rtt_avg_ms)}ms")
except Exception:
lines.append(f"{name}: DOWN")
await update.message.reply_text("\n".join(lines))
app = Application.builder().token("YOUR_TOKEN").build()
app.add_handler(CommandHandler("status", status))
app.run_polling()
Stay updated
Join @FastTGProxyMT for instant alerts when servers move or new proxies launch.
Join Telegram ChannelRunning through TGFast
If your server is in a restricted region, configure python-telegram-bot to route through TGFast:
app = Application.builder().token("YOUR_TOKEN").proxy("https://your TGFast card hostname:57691").build()This makes the bot itself censorship-resistant.Deploy with systemd
Create a systemd service so the bot restarts automatically. Save as /etc/systemd/system/tgstatus.service:
[Unit]
Description=TGFast Status Bot
After=network.target
[Service]
User=botuser
ExecStart=/usr/bin/python3 /opt/tgstatus/bot.py
Restart=always
[Install]
WantedBy=multi-user.target
Then sudo systemctl enable --now tgstatus.Extending the bot
Easy additions: per-user favorite server, country auto-detection via IP geolocation, alert notifications when a server goes down. Pull requests welcome on our community GitHub mirror.