Skip to content

muhammedadnank/UptimeRobot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

154 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– UptimeRobot Telegram Bot

Full control of your UptimeRobot account โ€” directly from Telegram.

Python Pyrogram MongoDB Deploy on Railway Deploy on Render License: MIT Version


โœจ Features

Category Capabilities
๐Ÿ”‘ Auth Each user links their own UptimeRobot API key โ€” securely stored per-user in MongoDB
๐Ÿ“Š Status Dashboard Paginated monitor cards (5/page) with live โธ๏ธ Pause / โ–ถ๏ธ Resume / ๐Ÿ—‘ Delete buttons per monitor
๐Ÿ“ˆ Stats Visual progress bar uptime display (โ–“โ–“โ–“โ–“โ–“โ–“โ–‘โ–‘โ–‘โ–‘) with ๐ŸŸข๐ŸŸก๐Ÿ”ด color grading for 7d / 30d / 90d
๐Ÿ”” Alerts Unified timeline feed (newest first), filter by ๐Ÿ“‹ All or ๐Ÿ”ด Down only
๐Ÿ‘ค Account Monitor usage progress bar, plan badge (Free/Pro), email, check interval
๐Ÿ”” Alert Contacts List, add (Email / Telegram / Webhook / Slack), delete
๐ŸชŸ Maintenance Windows List, create (Once / Daily / Weekly / Monthly), delete
๐Ÿ“„ Public Status Pages List, create, delete
๐Ÿ” Inline Search Type @bot <query> in any chat to instantly share monitor status
๐Ÿ”’ Security Per-user API key isolation, confirmation prompt on all destructive actions
๐ŸŒ Multi-user Unlimited users, each with their own UptimeRobot account
๐Ÿ‘ฎ Admin Panel Broadcast, ban/unban, live bot stats (memory + uptime), force-subscribe, restart

๐Ÿ“‹ Command Reference

๐Ÿ”‘ Key Management

Command Description
/setkey <api_key> Link your UptimeRobot API key
/mykey Check whether an API key is currently set
/deletekey Remove your stored API key

๐Ÿ–ฅ๏ธ Monitors

Command Description
/status Paginated monitor cards with quick Pause / Resume / Delete buttons
/stats Visual uptime % bars and average response times
/alerts Unified alert timeline โ€” filter by All or Down only
/add Guided 3-step monitor creation
/pause <id> Pause a monitor
/resume <id> Resume a paused monitor
/delete <id> Delete a monitor (confirmation required)

๐Ÿ‘ค Account & Contacts

Command Description
/account Account details with monitor usage progress bar
/contacts List all alert contacts
/addcontact Add a new contact (guided)
/delcontact <id> Delete a contact

๐ŸชŸ Maintenance & Status Pages

Command Description
/mwindow List maintenance windows
/addmwindow Create a new maintenance window
/delmwindow <id> Delete a maintenance window
/psp List public status pages
/addpsp Create a new status page
/delpsp <id> Delete a status page

๐Ÿ”ง General

Command Description
/start Welcome screen with live monitor summary (returning users)
/menu Interactive control panel with live account summary
/cancel Cancel any in-progress multi-step operation

๐Ÿ‘ฎ Admin Only

Command Description
/botstats Users count, memory usage, uptime, force-sub status
/broadcast Reply to any message with this to send it to all users
/ban <id> [reason] Ban a user from using the bot
/unban <id> Unban a user
/bannedlist List all banned users
/setfsub <@channel> Enable force-subscribe for a channel
/delfsub Disable force-subscribe
/restart Restart the bot process

๐Ÿ’ก Use /status to find monitor IDs needed for pause / resume / delete. ๐Ÿ‘ฎ Admin commands only work for user IDs listed in the ADMINS env variable.


๐Ÿ” Inline Search

Type @yourbotusername in any Telegram chat to search your monitors without opening the bot.

Query Result
@bot Overview summary + all monitors
@bot mysite Search by name or URL
@bot down Only down monitors
@bot up Only up monitors
@bot paused Only paused monitors

Each result shows monitor name, status, URL, uptime %, response time, and ID. Tap a result to share it directly into the chat.

โš ๏ธ Enable inline mode first: BotFather โ†’ your bot โ†’ Bot Settings โ†’ Inline Mode โ†’ Enable


๐Ÿ“ Project Structure

UptimeRobot-main/
โ”‚
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ main.py             # Module entrypoint (`python -m app.main`)
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”œโ”€โ”€ db.py           # MongoDB layer (users/config/indexes)
โ”‚   โ”‚   โ”œโ”€โ”€ api_cache.py    # get_api_for() per-user API cache
โ”‚   โ”‚   โ””โ”€โ”€ uptime_robot.py # UptimeRobot REST API wrapper (aiohttp)
โ”‚   โ””โ”€โ”€ handlers/
โ”‚       โ”œโ”€โ”€ middleware.py   # check_banned ยท check_force_sub ยท check_all
โ”‚       โ”œโ”€โ”€ monitors.py     # /status /stats /alerts /add /pause /resume /delete + UI builders
โ”‚       โ”œโ”€โ”€ account.py      # /account with usage progress bar
โ”‚       โ”œโ”€โ”€ contacts.py     # /contacts /addcontact /delcontact
โ”‚       โ”œโ”€โ”€ mwindow.py      # /mwindow /addmwindow /delmwindow
โ”‚       โ”œโ”€โ”€ psp.py          # /psp /addpsp /delpsp
โ”‚       โ”œโ”€โ”€ callbacks.py    # Inline keyboard callbacks + main_keyboard()
โ”‚       โ”œโ”€โ”€ admin.py        # /botstats /broadcast /ban /unban /bannedlist /setfsub /delfsub /restart
โ”‚       โ””โ”€โ”€ inline.py       # Inline mode โ€” @bot <query> monitor search
โ”‚
โ”œโ”€โ”€ .env.example            # Environment variable template
โ”œโ”€โ”€ requirements.txt        # Python dependencies
โ”œโ”€โ”€ Procfile                # worker: python -m app.main
โ”œโ”€โ”€ railway.toml            # Railway deploy config
โ”œโ”€โ”€ README.md               # This file
โ””โ”€โ”€ LICENSE                 # MIT License

๐Ÿš€ Getting Started

Step 1 โ€” Gather Credentials

Variable Where to get it
API_ID my.telegram.org โ†’ API Development Tools
API_HASH my.telegram.org โ†’ API Development Tools
BOT_TOKEN @BotFather โ†’ /newbot
MONGODB_URI cloud.mongodb.com โ†’ Free Cluster โ†’ Connect โ†’ Drivers
ADMINS Your Telegram user ID โ€” get it from @userinfobot
PORT Set to 10000 on Render, or any free port locally

Each user's UptimeRobot API key is stored in MongoDB โ€” it is not an env variable.


Step 2 โ€” MongoDB Atlas (Free Tier)

  1. Sign up at cloud.mongodb.com
  2. Create a free M0 cluster
  3. Database Access โ†’ add a user with a password
  4. Network Access โ†’ allow 0.0.0.0/0
  5. Connect โ†’ Drivers โ†’ copy your connection string:
    mongodb+srv://<user>:<password>@cluster0.xxxxx.mongodb.net/?retryWrites=true&w=majority
    

Step 3 โ€” Install & Run Locally

# Clone
git clone https://github.com/muhammedadnank/UptimeRobot.git
cd UptimeRobot

# Install dependencies
pip install -r requirements.txt

# Configure environment
cp .env.example .env
# Edit .env โ€” fill in API_ID, API_HASH, BOT_TOKEN, MONGODB_URI, ADMINS, PORT

# Start
python -m app.main

โ˜๏ธ Deployment

Render (Recommended)

  1. render.com โ†’ New โ†’ Background Worker
  2. Connect your GitHub repo
  3. Set:
    • Build Command: pip install -r requirements.txt
    • Start Command: python -m app.main
  4. Add all environment variables (set PORT=10000)
  5. Create Background Worker โ†’ Deploy โœ…

Railway

  1. Push your code to GitHub
  2. railway.app โ†’ New Project โ†’ Deploy from GitHub repo
  3. Select your repo
  4. Variables tab โ†’ add all env vars
  5. Done โ€” Railway auto-deploys on every push โœ…

โš™๏ธ Environment Variables

# Telegram MTProto credentials โ€” my.telegram.org
API_ID=12345678
API_HASH=your_api_hash_here

# Bot token โ€” @BotFather
BOT_TOKEN=your_bot_token_here

# MongoDB Atlas connection string
MONGODB_URI=mongodb+srv://<user>:<password>@cluster0.xxxxx.mongodb.net/?retryWrites=true&w=majority

# Admin user IDs โ€” space or comma separated
# Get your ID from @userinfobot on Telegram
ADMINS=123456789

# HTTP port for health check (Render uses 10000 by default)
PORT=10000

๐Ÿ› ๏ธ Tech Stack

Package Purpose
kurigram Telegram MTProto โ€” actively maintained Pyrogram fork
motor Async MongoDB driver
aiohttp Async HTTP client for UptimeRobot API
tgcrypto Fast Telegram encryption (speeds up MTProto)
psutil System stats for /botstats (memory, uptime)

๐Ÿ—„๏ธ Database Schema

Collection: users

Field Type Description
telegram_id int Unique index โ€” Telegram user ID
api_key str UptimeRobot API key (ur_โ€ฆ or u0000000-โ€ฆ)
banned bool Whether the user is banned
ban_reason str Reason for ban
banned_at datetime When the user was banned
created_at datetime When the user first ran /setkey
updated_at datetime Last API key update
last_active datetime Last API call timestamp

Collection: config

Field Type Description
key str Unique index โ€” config key (e.g. force_sub)
value str Config value (e.g. @yourchannel or -1001234567890)

๐Ÿ› Troubleshooting

Symptom Fix
Bot doesn't respond Check BOT_TOKEN is correct and bot is not blocked
api_key not found error Regenerate key at dashboard.uptimerobot.com โ†’ My Settings โ†’ API Settings
MongoDB connection error Whitelist your server IP in Atlas โ†’ Network Access
API_ID / API_HASH errors These come from my.telegram.org, not BotFather
/setkey says invalid key Key must start with ur_ or match u1234567-xxxxโ€ฆ format
Multi-step flow stuck Send /cancel to reset state
Admin commands not working Add your Telegram user ID to ADMINS env variable
Force-sub not working Bot must be admin in the channel. Use @username or channel ID โ€” not a phone number
Inline mode not working BotFather โ†’ Bot Settings โ†’ Inline Mode โ†’ Enable
Render deploy times out Ensure PORT env var is set โ€” health server must bind a port

๐Ÿ“ Notes

  • Private chats only โ€” group chats are not supported
  • Multi-step flows auto-expire after 10 minutes of inactivity โ€” send /cancel to reset manually
  • UptimeRobot Free plan: 50 monitors, 5-minute check interval
  • Alert timestamps displayed in IST (UTC+5:30)
  • Weekly maintenance windows: day-of-week (1 = Mon โ€ฆ 7 = Sun)
  • Monthly maintenance windows: day-of-month (1 โ€“ 28)
  • Status page displays 5 monitors per page โ€” use โ—€๏ธ / โ–ถ๏ธ to navigate
  • API keys stored as plaintext โ€” enable Atlas Encryption at Rest for production security

๐Ÿค Contributing

  1. Fork the repo
  2. Create a branch: git checkout -b feature/your-feature
  3. Commit: git commit -m "Add your feature"
  4. Push: git push origin feature/your-feature
  5. Open a Pull Request

Please keep PRs focused โ€” one feature or fix per PR.


๐Ÿ“„ License

MIT License โ€” free to use, modify, and distribute. See LICENSE for details.


Made with โค๏ธ by muhammedadnank

About

๐Ÿค– UptimeRobot Telegram Bot Full control of your UptimeRobot account โ€” directly from Telegram.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages