LinkShareBot is a modern Telegram bot that allows you to share and manage unlimited Telegram channel links with automatic invite link generation and management.
Powered by Pyrogram, it provides a seamless experience for users to join channels through secure, auto-expiring links. The bot includes advanced features like force subscription, bulk link generation, and request link management.
-
/addch <channel_id>โ Add a channel to the bot (admin only) -
/delch <channel_id>โ Remove a channel from the bot (admin only) -
/channelsโ Show all connected channels as buttons (paginated) -
/reqlinkโ Show all request links for channels (paginated) -
/linksโ Show all channel links as text (paginated) -
/bulklink <id1> <id2> ...โ Generate links for multiple channel IDs at once -
/channelsโ Show all connected channel IDs and names (paginated, with next/prev buttons and auto-deleting "please wait..." status) -
/reqtimeโ Set the auto-approve request timer duration. -
/reqmodeโ Toggle auto request approval mode (ON/OFF). -
/approveonโ Enable auto request approval for a specific channel. -
/approveoffโ Disable auto request approval for a specific channel. -
/approveallโ Approve all pending join requests in a channel using userbot (make sure to fill your session string inapprove.py).
/statsโ Show bot stats (owner only)/statusโ Show bot status (admins)/broadcastโ Broadcast a message to all users (admins)/cleanupโ Remove inactive users from database (admins)
Below are the required and optional environment variables for deployment.
API_ID= # Required - Get from https://my.telegram.org
API_HASH= # Required - From https://my.telegram.org
TG_BOT_TOKEN= # Required - Get from @BotFather
OWNER_ID= # Required - Your Telegram user ID
ADMINS= # Required - Admin user IDs (space separated)
DB_URL= # Required - MongoDB connection string
DB_NAME= # Optional - MongoDB database name (default: LinkShareBot)
DATABASE_CHANNEL= # Required - Private channel ID for link storageWhere do I get each key?
| Key | Where to Get It | Steps | Notes |
|---|---|---|---|
API_ID & API_HASH |
my.telegram.org โ API Development Tools | 1) Log in with Telegram โ 2) Open API Development Tools โ 3) Create app โ 4) Copy values | Keep these private. Needed by both userbot & bot client. |
TG_BOT_TOKEN |
@BotFather | 1) /newbot โ 2) Set name & username โ 3) Copy the token | Rotate if leaked. Store in .env. |
OWNER_ID |
Telegram Profile you own | 1) Use @userinfobot or @getmyid_bot โ 2) Send any message to get your ID โ 3) Copy the number | Must be a single number (yours). |
ADMINS |
Telegram Profiles of admins | 1) Get IDs via @userinfobot โ 2) Add multiple IDs space-separated โ 3) Include OWNER_ID if needed | Space-separated list of admin IDs. |
DB_URL |
MongoDB Atlas |
1) Create free cluster โ
2) Add database user & IP allowlist โ
3) Copy connection string (mongodb+srv://...)
|
Required for persistence (channels, users, etc.). |
DATABASE_CHANNEL |
Telegram Channel you own |
1) Create private channel โ
2) Add your bot as admin โ
3) Get ID via @userinfobot or @getmyid_bot
|
Private channel for link storage. |
Details
๐ต Deploy LinkShareBot on VPS
# Step 1: Update & Install Dependencies
sudo apt update && sudo apt upgrade -y
sudo apt install -y git curl python3-pip python3-venv ffmpeg unzip tmux
# Step 2: Clone & Setup
git clone https://github.com/yourusername/LinkShareBot
cd LinkShareBot
tmux new -s LinkShareBot
# Inside tmux:
python3 -m venv venv
source venv/bin/activate
pip install -U pip && pip install -r requirements.txt
# Create .env file with your environment variables
nano .env
# Run the bot
python3 main.py
### Useful Commands
tmux detach # Use Ctrl+B, then D
tmux attach-session -t LinkShareBot # Reattach session
tmux kill-session -t LinkShareBot # Kill bot session
rm -rf LinkShareBot # Uninstall botDetails
### Step 1: Clone Repo
git clone https://github.com/yourusername/LinkShareBot
cd LinkShareBot
### Step 2: Create .env File
nano .env
# Paste your environment variables here and save (Ctrl+O, Enter, Ctrl+X)
### Step 3: Build Image
docker build -t linksharebot .
### Step 4: Run Container
docker run -d --name linkshare --env-file .env --restart unless-stopped linksharebot
### Step 5: Manage Container
docker logs -f linkshare # View logs (Ctrl+C to exit)
docker stop linkshare # Stop container
docker start linkshare # Start again
docker rm -f linkshare # Remove container
docker rmi linksharebot # Remove image| Platform | Deploy Link |
|---|---|
| ๐ Heroku Deploy |
- แดสแดาแดแดแด แดกษชแดส แดแดssษชแดษด สส สแดแดแด


