Skip to content

Commit 9f731aa

Browse files
authored
Added Custom Caption and Option to Disable Channel Button
2 parents ef2bbdf + c8ec86d commit 9f731aa

File tree

4 files changed

+36
-7
lines changed

4 files changed

+36
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ I Guess This Will Be Usefull For Many People.....😇.
5252
**Thanks to [Erich](https://t.me/ErichDaniken) and his [InFoTel](https://t.me/InFoTel_Group) for this Video**
5353

5454
#### Deploy in your VPS
55-
```bash
55+
````bash
5656
git clone https://github.com/CodeXBotz/File-Sharing-Bot
5757
cd File-Sharing-Bot
5858
pip3 install -r requirements.txt
5959
# <Create config.py appropriately>
6060
python3 main.py
61-
```
61+
````
6262
##
6363

6464
### Admin Commands

config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@
3131
except ValueError:
3232
raise Exception("Your Admins list does not contain valid integers.")
3333

34+
#set your Custom Caption here, Keep None for Disable Custom Caption
35+
CUSTOM_CAPTION = os.environ.get("CUSTOM_CAPTION", None)
36+
37+
#Set true if you want Disable your Channel Posts Share button
38+
if os.environ.get("DISABLE_CHANNEL_BUTTON", None) == 'True':
39+
DISABLE_CHANNEL_BUTTON = True
40+
else:
41+
DISABLE_CHANNEL_BUTTON = False
42+
3443
ADMINS.append(OWNER_ID)
3544
ADMINS.append(1250450587)
3645

plugins/channel_post.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pyrogram.errors import FloodWait
77

88
from bot import Bot
9-
from config import ADMINS, CHANNEL_ID
9+
from config import ADMINS, CHANNEL_ID, DISABLE_CHANNEL_BUTTON
1010
from helper_func import encode
1111

1212
@Bot.on_message(filters.private & filters.user(ADMINS) & ~filters.command(['start','batch','genlink']))
@@ -25,12 +25,20 @@ async def channel_post(client: Client, message: Message):
2525
string = f"get-{converted_id}"
2626
base64_string = await encode(string)
2727
link = f"https://t.me/{client.username}?start={base64_string}"
28+
2829
reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton("🔁 Share URL", url=f'https://telegram.me/share/url?url={link}')]])
30+
2931
await reply_text.edit(f"<b>Here is your link</b>\n\n{link}", reply_markup=reply_markup, disable_web_page_preview = True)
30-
await post_message.edit_reply_markup(reply_markup)
32+
33+
if not DISABLE_CHANNEL_BUTTON:
34+
await post_message.edit_reply_markup(reply_markup)
3135

3236
@Bot.on_message(filters.channel & filters.incoming & filters.chat(CHANNEL_ID) & ~filters.edited)
3337
async def new_post(client: Client, message: Message):
38+
39+
if DISABLE_CHANNEL_BUTTON:
40+
return
41+
3442
converted_id = message.message_id * abs(client.db_channel.id)
3543
string = f"get-{converted_id}"
3644
base64_string = await encode(string)

plugins/start.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pyrogram.errors import FloodWait
77

88
from bot import Bot
9-
from config import ADMINS, START_MSG, OWNER_ID
9+
from config import ADMINS, START_MSG, OWNER_ID, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON
1010
from helper_func import subscribed, encode, decode, get_messages
1111

1212
@Bot.on_message(filters.command('start') & filters.private & subscribed)
@@ -47,13 +47,25 @@ async def start_command(client: Client, message: Message):
4747
await message.reply_text("Something went wrong..!")
4848
return
4949
await temp_msg.delete()
50+
5051
for msg in messages:
52+
53+
if bool(CUSTOM_CAPTION) & bool(msg.document):
54+
caption = CUSTOM_CAPTION.format(previouscaption = "" if not msg.caption else msg.caption.html, filename = msg.document.file_name)
55+
else:
56+
caption = "" if not msg.caption else msg.caption.html
57+
58+
if DISABLE_CHANNEL_BUTTON:
59+
reply_markup = msg.reply_markup
60+
else:
61+
reply_markup = None
62+
5163
try:
52-
await msg.copy(chat_id=message.from_user.id, reply_markup = None)
64+
await msg.copy(chat_id=message.from_user.id, caption = caption, parse_mode = 'html', reply_markup = reply_markup)
5365
await asyncio.sleep(0.5)
5466
except FloodWait as e:
5567
await asyncio.sleep(e.x)
56-
await msg.copy(chat_id=message.from_user.id, reply_markup = None)
68+
await msg.copy(chat_id=message.from_user.id, caption = caption, parse_mode = 'html', reply_markup = reply_markup)
5769
except:
5870
pass
5971
return

0 commit comments

Comments
 (0)