Last active
December 27, 2024 18:04
-
-
Save nuhmanpk/3020cc3a0d7ed658aa4d8900781e1a6d to your computer and use it in GitHub Desktop.
Add Force Subscribe To Your Bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| # [email protected] | Bughunter0 | Nuhman |
Author
piro?
#Suggestion
Defining app makes more clear to newbies I guess 👍
app = Client(.......)
And handling other exception also could be helpful if something unexpected goes wrong...
except Exception as error:
return await update.reply(f"Error\n{error}",True)
For usernotparticipant need to be return 🥺 else it won't block users to join
Instead continues with further codes
How to use this?
Can i use this cod in c/c++ language
Can i use this cod in c/c++ language
No
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
Hy piro