0% found this document useful (0 votes)
77 views3 pages

Telegram Bot Creating Tools

This document provides a step-by-step guide to restrict a Telegram bot's access to only members of a specified Telegram channel using the Telegram Bot API. It includes prerequisites, instructions for adding the bot as an admin, obtaining the channel username, and implementing the bot logic in Python. Additionally, it offers hosting options and suggestions for enhancing security and accessibility for non-coders.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views3 pages

Telegram Bot Creating Tools

This document provides a step-by-step guide to restrict a Telegram bot's access to only members of a specified Telegram channel using the Telegram Bot API. It includes prerequisites, instructions for adding the bot as an admin, obtaining the channel username, and implementing the bot logic in Python. Additionally, it offers hosting options and suggestions for enhancing security and accessibility for non-coders.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

To make a bot accessible only to users who have joined your Telegram channel, you can

implement a channel membership check in your bot using the Telegram Bot API.

Here’s how to do it:

---

✅ Step-by-step to Make Bot Work Only for Channel Members


🔧 1. Prerequisites
A Telegram bot (@BotFather helps you create one)

A Telegram channel where you want users to join

You must be an admin in that channel

---

📍 2. Add Bot to the Channel as an Admin


Go to your channel → Members → Add Admin → Select your bot → Give at least “Read
Members” permission

---

🧪 3. Get Channel Username


Example: If your channel link is https://t.me/wallpaperloots, then your channel username is
@wallpaperloots.

---

👨‍💻 4. Bot Logic (Using Python + python-telegram-bot or Pyrogram)


Here’s an example in Python (Pyrogram):

from pyrogram import Client, filters


from pyrogram.errors import UserNotParticipant

API_ID = 123456 # Get from https://my.telegram.org


API_HASH = "your_api_hash"
BOT_TOKEN = "your_bot_token"
CHANNEL_USERNAME = "wallpaperloots" # Without @

app = Client("bot", api_id=API_ID, api_hash=API_HASH, bot_token=BOT_TOKEN)

@app.on_message(filters.private)
async def check_membership(client, message):
try:
# Try to get user info from the channel


await client.get_chat_member(CHANNEL_USERNAME, message.from_user.id)
await message.reply(" You're a member! Access granted.")

# Continue with your bot logic here


except UserNotParticipant:
# User is not a member

❌ 👉 Join
join_link = f"https://t.me/{CHANNEL_USERNAME}"
await message.reply(f" You must join our channel first to use this bot.\n\n
here: {join_link}")

app.run()

---

⚠️ 5. Hosting the Bot


You can use free services like:

Render

Railway

Replit (works best for beginners)

---

💡 Bonus: You can make it more secure by:


Adding a /start command that checks membership before allowing access

Redirecting to your channel with an inline keyboard button

---
🧩 If You’re Not a Coder?
You can use @ControllerBot or BotFather + Botmakers to do basic linking but restricting
access based on membership needs code.

---

Would you like a Replit version (no install needed)? Let me know and I’ll give you a
ready-to-run link.

You might also like