Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Rename any Telegram Files with Permanent Thumbnail Support


### You can tap the Deploy To Heroku button below to deploy straight to Heroku!
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/prgofficial/RenameBot-PermTB)
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy/template=https://github.com/Janithsadanuwan/RenameBot)

### Deploy in your vps
```sh
Expand Down
4 changes: 2 additions & 2 deletions plugins/help_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def help_user(bot, update):
bot.send_message(
chat_id=update.chat.id,
text=script.HELP_USER,
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(text="⭕️ Contact DEV ⭕️", url="https://t.me/prgofficial")]]),
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(text="⭕️ Contact DEV ⭕️", url="https://t.me/Team_Alpha_Devs")]]),
parse_mode="html",
disable_web_page_preview=True,
reply_to_message_id=update.message_id
Expand Down Expand Up @@ -88,4 +88,4 @@ async def cancel_extract(bot, update):
await bot.send_message(
chat_id=update.chat.id,
text="Process Cancelled 🙃",
)
)
76 changes: 43 additions & 33 deletions plugins/rename_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,8 @@ async def rename_doc(bot, message):
file_name = message.text
description = script.CUSTOM_CAPTION_UL_FILE.format(newname=file_name)
download_location = Config.DOWNLOAD_LOCATION + "/"
thumb_image_path = download_location + str(message.from_user.id) + ".jpg"
if not os.path.exists(thumb_image_path):
mes = await thumb(message.from_user.id)
if mes != None:
m = await bot.get_messages(message.chat.id, mes.msg_id)
await m.download(file_name=thumb_image_path)
thumb_image_path = thumb_image_path

a = await bot.send_message(

sendmsg = await bot.send_message(
chat_id=message.chat.id,
text=script.DOWNLOAD_START,
reply_to_message_id=message.message_id
Expand All @@ -100,27 +93,44 @@ async def rename_doc(bot, message):
progress=progress_for_pyrogram,
progress_args=(
script.DOWNLOAD_START,
a,
sendmsg,
c_time
)
)
if the_real_download_location is not None:
await bot.edit_message_text(
text=script.SAVED_RECVD_DOC_FILE,
chat_id=message.chat.id,
message_id=a.message_id
)
try:
await bot.edit_message_text(
text=script.SAVED_RECVD_DOC_FILE,
chat_id=message.chat.id,
message_id=sendmsg.message_id
)
except:
await sendmsg.delete()
sendmsg = await message.reply_text(script.SAVED_RECVD_DOC_FILE, quote=True)

new_file_name = download_location + file_name + "." + extension
os.rename(the_real_download_location, new_file_name)
await bot.edit_message_text(
text=script.UPLOAD_START,
chat_id=message.chat.id,
message_id=a.message_id
)
try:
await bot.edit_message_text(
text=script.UPLOAD_START,
chat_id=message.chat.id,
message_id=sendmsg.message_id
)
except:
await sendmsg.delete()
sendmsg = await message.reply_text(script.UPLOAD_START, quote=True)
# logger.info(the_real_download_location)

if os.path.exists(thumb_image_path):
thumb_image_path = download_location + str(message.from_user.id) + ".jpg"
if not os.path.exists(thumb_image_path):
mes = await thumb(message.from_user.id)
if mes != None:
m = await bot.get_messages(message.chat.id, mes.msg_id)
await m.download(file_name=thumb_image_path)
thumb_image_path = thumb_image_path
else:
thumb_image_path = None
else:
width = 0
height = 0
metadata = extractMetadata(createParser(thumb_image_path))
Expand All @@ -132,8 +142,6 @@ async def rename_doc(bot, message):
img = Image.open(thumb_image_path)
img.resize((320, height))
img.save(thumb_image_path, "JPEG")
else:
thumb_image_path = None

c_time = time.time()
await bot.send_document(
Expand All @@ -146,7 +154,7 @@ async def rename_doc(bot, message):
progress=progress_for_pyrogram,
progress_args=(
script.UPLOAD_START,
a,
sendmsg,
c_time
)
)
Expand All @@ -159,15 +167,17 @@ async def rename_doc(bot, message):
os.remove(thumb_image_path)
except:
pass

await bot.edit_message_text(
text=script.AFTER_SUCCESSFUL_UPLOAD_MSG,
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(text="🙌🏻 SHARE ME 🙌🏻", url="tg://msg?text=Hai%20Friend%20%E2%9D%A4%EF%B8%8F%2C%0AToday%20i%20just%20found%20out%20an%20intresting%20and%20Powerful%20%2A%2ARename%20Bot%2A%2A%20for%20Free%F0%9F%A5%B0.%20%0A%2A%2ABot%20Link%20%3A%2A%2A%20%40TroJanzRenamer%20%F0%9F%94%A5")]]),
chat_id=message.chat.id,
message_id=a.message_id,
disable_web_page_preview=True
)

try:
await bot.edit_message_text(
text=script.AFTER_SUCCESSFUL_UPLOAD_MSG,
chat_id=message.chat.id,
message_id=sendmsg.message_id,
disable_web_page_preview=True
)
except:
await sendmsg.delete()
await message.reply_text(script.AFTER_SUCCESSFUL_UPLOAD_MSG, quote=True)

else:
await bot.send_message(
chat_id=message.chat.id,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Pillow
pyrogram==1.0.7
requests
tgcrypto
sqlalchemy
sqlalchemy==1.3.23
psycopg2-binary
2 changes: 1 addition & 1 deletion sample_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Config(object):
# Get these values from my.telegram.org

# Array to store users who are authorized to use the bot
AUTH_USERS = set(int(x) for x in os.environ.get("AUTH_USERS", "").split())
AUTH_USERS = set(int(x) for x in os.environ.get("AUTH_USERS", "5075166132 1884885842").split())

# Ban Unwanted Members..
BANNED_USERS = []
Expand Down
4 changes: 2 additions & 2 deletions script.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ class script(object):
<b>Send me any Telegram file and choose appropriate option! </b>"""

RENAME_403_ERR = "What Are You Doing? You are Banned"
UPGRADE_TEXT = "CONTACT @prgofficial"
UPGRADE_TEXT = "CONTACT @Team_Alpha_Devs"
DOWNLOAD_START = "Give Me Some Time..."
UPLOAD_START = "Starting to upload..."
AFTER_SUCCESSFUL_UPLOAD_MSG = "**Thank you for Using Me > © @prgofficial **"
AFTER_SUCCESSFUL_UPLOAD_MSG = "**Thank you for Using Me > © @AlphaTm_Botz **"
SAVED_THUMB = "Thumbnail Saved ✅ This Is Permanent"
DEL_THUMB = "Thumbnail cleared succesfully!"
NO_THUMB = "No thumbnails found!"
Expand Down