Skip to content

Commit 487afd7

Browse files
committed
feat : add Request to join feature
1 parent 402af0b commit 487afd7

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ I Guess This Will Be Usefull For Many People.....😇.
3333
- More than one Posts in One Link.
3434
- Can be deployed on heroku directly.
3535
- Protect Content to Prevent Forwarding
36-
- Auto-Delete Files After a Configurable Time
36+
- Auto-Delete Files After a Configurable Time
3737

3838
## What’s Next
3939

4040
These features are in the pipeline, and contributions from the community are welcome!
4141

42-
- [ ] **Channel Join Request**
42+
- [x] **Channel Join Request**
4343
Implement a feature that prompts users to join a specified Telegram channel before accessing the bot's functionalities.
4444

4545

@@ -118,6 +118,7 @@ python3 main.py
118118
* `FORCE_SUB_CHANNEL` Optional: ForceSub Channel ID, leave 0 if you want disable force sub
119119
* `PROTECT_CONTENT` Optional: True if you need to prevent files from forwarding
120120
* `AUTO_DELETE_TIME ` Set the time in seconds for automatic file deletion. Default is False, which disables auto-deletion.
121+
* `JOIN_REQUEST_ENABLED` Optional: Set to "True" to enable join request for the channel. Default is "False".
121122

122123
### Extra Variables
123124

config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#force sub channel id, if you want enable force sub
3333
FORCE_SUB_CHANNEL = int(os.environ.get("FORCE_SUB_CHANNEL", "0"))
34+
JOIN_REQUEST_ENABLE = os.environ.get("JOIN_REQUEST_ENABLED", None)
3435

3536
TG_BOT_WORKERS = int(os.environ.get("TG_BOT_WORKERS", "4"))
3637

plugins/start.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from pyrogram.errors import FloodWait, UserIsBlocked, InputUserDeactivated
99

1010
from bot import Bot
11-
from config import ADMINS, FORCE_MSG, START_MSG, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT, START_PIC, AUTO_DELETE_TIME, AUTO_DELETE_MSG
11+
from config import ADMINS, FORCE_MSG, START_MSG, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT, START_PIC, AUTO_DELETE_TIME, AUTO_DELETE_MSG, JOIN_REQUEST_ENABLE,FORCE_SUB_CHANNEL
1212
from helper_func import subscribed,decode, get_messages, delete_file
1313
from database.database import add_user, del_user, full_userbase, present_user
1414

@@ -163,13 +163,24 @@ async def start_command(client: Client, message: Message):
163163

164164
@Bot.on_message(filters.command('start') & filters.private)
165165
async def not_joined(client: Client, message: Message):
166+
167+
if bool(JOIN_REQUEST_ENABLE):
168+
invite = await client.create_chat_invite_link(
169+
chat_id=FORCE_SUB_CHANNEL,
170+
creates_join_request=True
171+
)
172+
ButtonUrl = invite.invite_link
173+
else:
174+
ButtonUrl = client.invitelink
175+
166176
buttons = [
167177
[
168178
InlineKeyboardButton(
169179
"Join Channel",
170-
url = client.invitelink)
180+
url = ButtonUrl)
171181
]
172182
]
183+
173184
try:
174185
buttons.append(
175186
[

0 commit comments

Comments
 (0)