تخطَّ إلى المحتوى
ARAB CODEمجتمع المطورين العرب

telegram-hosting-bot

v1.0.0MITZIP206 KB١٠ أكتوبر ٢٠٢٦

إدارته خوادم بتروداكتل و انشاء سيرفرات مستخدمين

Telegram Hosting Bot

A production-minded Telegram control plane for Pterodactyl hosting

Python CI Telegram Pterodactyl License

Create, provision, manage, and monetize Python and Node.js hosting directly from Telegram.

Features · Architecture · Quick Start · Configuration · Commands · Security · Contact


Overview

telegram-hosting-bot is a Telegram-first hosting automation layer built for Pterodactyl. It turns a Pterodactyl installation into a simple, branded hosting storefront and control panel for customers and administrators.

The project is designed for operators who want to offer managed application hosting without exposing the full panel workflow to every customer. It supports free trials, resource selection, server ownership, lifecycle actions, invoices, and subscription messaging while keeping all credentials outside the repository.

Important: This repository is a reusable template. Never commit production bot tokens, Pterodactyl API keys, databases, or customer credentials.

Features

Customer experience

  • Guided server provisioning from Telegram inline buttons.
  • Python and Node.js egg discovery from the Pterodactyl Application API.
  • One configurable free trial per Telegram user.
  • Seven-day default trial lifecycle with automatic suspension after expiry.
  • Per-user server ownership checks.
  • Server list, status, resource information, suspend, unsuspend, and reinstall actions.
  • Subscription/contact flow for post-trial upgrades.
  • Branded welcome screen with a custom image and persistent keyboard.

Administrator experience

  • Admin-only resource wizard: egg → RAM → disk → CPU → account email.
  • RAM presets from 1G to 5G plus Infinite.
  • Disk presets from 1G to 10G.
  • CPU presets from 100% to 200% plus Infinite.
  • Automatic Pterodactyl user creation with generated credentials.
  • Resource-aware provisioning and formatted invoices.
  • Configurable pricing model for RAM, disk, and CPU.
  • Server renewal, egg switching, password changes, bulk suspension, and bulk unsuspension.
  • Official Telegram command menu registration.

Operations and security

  • Environment-based secret management.
  • SQLite persistence for local ownership and trial state.
  • Allocation refresh before provisioning to avoid stale allocation failures.
  • One retry for transient allocation/Wings errors.
  • No database, token, or API key is included in the public package.
  • MIT licensed and easy to extend.

Architecture

Telegram user
     │
     ▼
python-telegram-bot  ──────►  SQLite ownership/trial state
     │
     ▼
Pterodactyl Application API
     │
     ├── Users
     ├── Servers
     ├── Nests / Eggs
     ├── Allocations
     └── Server lifecycle actions
     │
     ▼
Pterodactyl Node + Wings + Docker

Quick Start

1. Clone and install

git clone https://github.com/YOUR_GITHUB_USERNAME/telegram-hosting-bot.git
cd telegram-hosting-bot
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

2. Configure secrets

cp .env.example .env

Fill in BOT_TOKEN, DEVELOPER_ID, PANEL_URL, and APPLICATION_API_KEY. Load the file with your process manager or export it before starting:

set -a
source .env
set +a
python main.py

For production, use a systemd service, Docker secret, or another secret manager instead of placing .env in a public directory.

3. Prepare Pterodactyl

  1. Create an Application API key with only the permissions required by your deployment.
  2. Confirm that your panel contains Python and Node.js eggs.
  3. Confirm that the node has free allocations.
  4. Set the Telegram numeric ID of the administrator in DEVELOPER_ID.
  5. Verify that the configured Docker images are available to Wings.

Configuration

All runtime configuration is environment-based. Start from .env.example.

VariablePurposeExample
BOT_TOKENTelegram Bot API token123456:replace-me
DEVELOPER_IDNumeric Telegram ID allowed to use admin tools123456789
PANEL_URLPterodactyl panel URLhttps://panel.example.com
APPLICATION_API_KEYPterodactyl Application API keyptla_replace_me
SERVER_DURATION_DAYSCustomer trial duration7
ADMIN_SERVER_DURATION_DAYSAdmin-created server duration30
PRICE_CURRENCYInvoice currency labelUSD
PRICE_RAM_PER_GBPrice per RAM GB1.0
PRICE_DISK_PER_GBPrice per disk GB0.10
PRICE_CPU_PER_100Price per 100% CPU1.0
BRAND_IMAGEWelcome image pathassets/eagle.jpg

Commands

Customers

CommandDescription
/startOpen the branded main menu
/createStart the guided hosting wizard
/serversList owned servers
/statusCheck bot and panel connectivity
/subscribeShow subscription instructions
/cancelCancel an active wizard

Administrator

CommandDescription
/statsShow panel statistics
/renew <server_id>Renew a server
/changegg <server_id>Change the server egg
/chpassChange a user password interactively
/suspendallSuspend all panel servers
/unsuspendallUnsuspend all panel servers

Invoice and pricing model

The administrator wizard produces an invoice containing the account credentials, server ID, egg, RAM, disk, CPU, expiry date, price, and configured brand footer.

The default editable pricing model is:

  • 1.00 USD per GB of RAM.
  • 0.10 USD per GB of disk.
  • 1.00 USD per 100% CPU.
  • Infinite resources are labelled Contact developer.

Change these values in .env; pricing is informational and should be connected to your own billing or payment workflow before commercial use.

Security

  • Keep .env private.
  • Rotate a token immediately if it appears in a log, screenshot, commit, or chat.
  • Never commit hosting_bot.sqlite3.
  • Use a dedicated Pterodactyl API key and the smallest practical permission set.
  • Review admin IDs before deploying the bot.
  • Do not paste customer passwords into public issues or support channels.

Read SECURITY.md for the vulnerability-reporting policy.

Project layout

.
├── assets/eagle.jpg       # Branded welcome image
├── bot.py                 # Telegram handlers and user/admin workflows
├── config.py              # Environment-backed configuration
├── main.py                # Application entry point
├── pterodactyl.py         # Pterodactyl API client and provisioning helpers
├── requirements.txt       # Python dependencies
├── .env.example           # Safe configuration template
├── LICENSE                # MIT license
└── SECURITY.md            # Security policy

Maintainer

Built and maintained by Monte for Arab Code Hosting.

Contributing

Pull requests are welcome. For substantial changes, open an issue first so the design and operational impact can be discussed. Please keep credentials, production URLs, customer data, and generated databases out of commits.

License

Released under the MIT License.

ARAB CODE HOSTING · ADMIN: MONTE