Skip to content

Commit 8531e4f

Browse files
authored
Merge pull request #8 from shahsad-klr/main
Added Extra Variables
2 parents b07b789 + 3514fe6 commit 8531e4f

File tree

4 files changed

+66
-12
lines changed

4 files changed

+66
-12
lines changed

README.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#### File-sharing-Bot
1+
# File-sharing-Bot
22

33
<p align="center">
44
<a href="https://www.python.org">
@@ -30,7 +30,7 @@ I Guess This Will Be Usefull For Many People.....😇.
3030

3131
**If you need any more modes in repo or If you find out any bugs, mention in [@codexbotzsupport ](https://www.telegram.dog/codexbotzsupport)**
3232

33-
#### Features
33+
### Features
3434
- Fully customisable.
3535
- Customisable welcome messages.
3636
- More than one Posts in One Link.
@@ -52,14 +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-
```
62-
##
61+
````
6362

6463
### Admin Commands
6564

@@ -80,9 +79,29 @@ python3 main.py
8079
* `OWNER_ID` Must enter Your Telegram Id
8180
* `CHANNEL_ID` Your Channel ID eg:- -100xxxxxxxx
8281
* `ADMINS` Optional: A space separated list of user_ids of Admins, they can only create links
83-
* `START_MESSAGE` Optional: start message of bot, use HTML parsemode format
82+
* `START_MESSAGE` Optional: start message of bot, use HTML and <a href='https://github.com/shahsad-klr/File-Sharing-Bot/blob/main/README.md#start_message'>fillings</a>
8483
* `FORCE_SUB_CHANNEL` Optional: ForceSub Channel ID, leave 0 if you want disable force sub
8584

85+
### Extra Variables
86+
87+
* `CUSTOM_CAPTION` put your Custom caption text if you want Setup Custom Caption, you can use HTML and <a href='https://github.com/shahsad-klr/File-Sharing-Bot/blob/main/README.md#custom_caption'>fillings</a> for formatting (only for documents)
88+
* `DISABLE_CHANNEL_BUTTON` Put True to Disable Channel Share Button, Default if False
89+
90+
### Fillings
91+
#### START_MESSAGE
92+
93+
* `{first}` - User first name
94+
* `{last}` - User last name
95+
* `{id}` - User ID
96+
* `{mention}` - Mention the user
97+
* `{username}` - Username
98+
99+
#### CUSTOM_CAPTION
100+
101+
* `{filename}` - file name of the Document
102+
* `{perviouscaption}` - Original Caption
103+
104+
86105
## Support
87106
Join Our [Telegram Group](https://www.telegram.dog/codexbotzsupport) For Support/Assistance And Our [Channel](https://www.telegram.dog/codexbotz) For Updates.
88107

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: 22 additions & 4 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
@@ -67,7 +79,13 @@ async def start_command(client: Client, message: Message):
6779
]
6880
)
6981
await message.reply_text(
70-
text = START_MSG.format(firstname = message.chat.first_name),
82+
text = START_MSG.format(
83+
first = message.chat.first_name,
84+
last = message.chat.last_name,
85+
username = None if not message.chat.username else '@' + message.chat.username,
86+
mention = message.from_user.mention,
87+
id = message.from_user.id
88+
),
7189
reply_markup = reply_markup,
7290
disable_web_page_preview = True,
7391
quote = True

0 commit comments

Comments
 (0)