Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CHANNEL_USERNAME = ""
- async def check_membership(user_id, bot):
- member = await bot.get_chat_member(CHANNEL_USERNAME, user_id)
- return member.status in ["member", "administrator", "creator"]
- async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
- user_id = update.effective_user.id
- if await check_membership(user_id, context.bot):
- await update.message.reply_text("✅ Welcome! You can now use the bot.")
- else:
- keyboard = [
- [InlineKeyboardButton("Join Channel", url=f"https://t.me/{CHANNEL_USERNAME[1:]}")],
- [InlineKeyboardButton("I've Joined", callback_data="check_join")]
- ]
- reply_markup = InlineKeyboardMarkup(keyboard)
- await update.message.reply_text(
- "🚫 You must join our channel before using this bot.",
- reply_markup=reply_markup
- )
Advertisement
Add Comment
Please, Sign In to add comment