diff --git a/README.md b/README.md index dc3bba2..1d0ef30 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/plugins/help_text.py b/plugins/help_text.py index bbb6429..5a9e3d7 100644 --- a/plugins/help_text.py +++ b/plugins/help_text.py @@ -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 @@ -88,4 +88,4 @@ async def cancel_extract(bot, update): await bot.send_message( chat_id=update.chat.id, text="Process Cancelled 🙃", - ) \ No newline at end of file + ) diff --git a/plugins/rename_file.py b/plugins/rename_file.py index 1d1d844..83716cf 100644 --- a/plugins/rename_file.py +++ b/plugins/rename_file.py @@ -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 @@ -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)) @@ -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( @@ -146,7 +154,7 @@ async def rename_doc(bot, message): progress=progress_for_pyrogram, progress_args=( script.UPLOAD_START, - a, + sendmsg, c_time ) ) @@ -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, diff --git a/requirements.txt b/requirements.txt index b8a3d92..ec8e7a7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,5 @@ Pillow pyrogram==1.0.7 requests tgcrypto -sqlalchemy +sqlalchemy==1.3.23 psycopg2-binary diff --git a/sample_config.py b/sample_config.py index 06c9f59..c7f73d1 100644 --- a/sample_config.py +++ b/sample_config.py @@ -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 = [] diff --git a/script.py b/script.py index ccc09ab..79249d1 100644 --- a/script.py +++ b/script.py @@ -4,10 +4,10 @@ class script(object): Send me any Telegram file and choose appropriate option! """ 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!"