Skip to content

Instantly share code, notes, and snippets.

@nuhmanpk
Last active December 27, 2024 18:04
Show Gist options
  • Select an option

  • Save nuhmanpk/3020cc3a0d7ed658aa4d8900781e1a6d to your computer and use it in GitHub Desktop.

Select an option

Save nuhmanpk/3020cc3a0d7ed658aa4d8900781e1a6d to your computer and use it in GitHub Desktop.
Add Force Subscribe To Your Bot
import pyrogram
from pyrogram import Client, filters
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from pyrogram.types import User, Message
from pyrogram.errors import UserNotParticipant
UPDATE_CHANNEL= "channel name without '@'"
# Follow me on Github - Github.com/nuhmanpk
# Join @BugHunterBots for more
FORCE_BUTTON = InlineKeyboardMarkup(
[[
InlineKeyboardButton('JOIN HERE 🔖', url=f"https://t.me/{UPDATE_CHANNEL}")
]]
)
@app.on_message(filters.command(["start"]) & filters.private)
async def start(bot, update):
try:
user = await bot.get_chat_member(UPDATE_CHANNEL, update.from_user.id)
if user.status == "member":
text = ""
reply_markup = # BUTTON_NAME
await update.reply_text(
text=text,
disable_web_page_preview=True,
reply_markup=reply_markup,
quote=True
)
# Add Your Code here to execute , if the
# user is member of Your channel
except UserNotParticipant:
await update.reply_text(
text="You need to Join my Updates Channel to Use me and Try Again\n @BugHunterBots",
disable_web_page_preview=True,
reply_markup=FORCE_BUTTON,
quote=True
)
return
# © BugHunterBots © 2021
# nuhmanpk@github.com | Bughunter0 | Nuhman
@pencemo
Copy link

pencemo commented Oct 31, 2021

Can i use this cod in c/c++ language

@Mrvishal2k2
Copy link

Can i use this cod in c/c++ language

No

@rajeshsaini2115
Copy link

rajeshsaini2115 commented Nov 27, 2021

add refresh callback button below join Channel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment