Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Commit

Permalink
UI Changes! 🌟
Browse files Browse the repository at this point in the history
- changes in status indicator.
  • Loading branch information
TheCaduceus authored Aug 11, 2022
2 parents 5534c82 + f1b7ce9 commit b61e94b
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions telegram_gcloner/utils/fire_save_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def run(self):
chat_id = update.effective_chat.id
user_id = update.effective_user.id
gd = GoogleDrive(user_id)
message = '╭──────⌈ 📥 Copying In Progress ⌋──────╮\n\n├ 📂 Target Directory:{}\n'.format(dest_folder['path'])
message = '╭──────⌈ 📥 Copying ⌋──────╮\n\n├ 📂 Destination:{}\n'.format(dest_folder['path'])
inline_keyboard = InlineKeyboardMarkup(
[[InlineKeyboardButton(text=f'🚫 Stop', callback_data=f'stop_task,{thread_id}')]])

Expand Down Expand Up @@ -105,15 +105,15 @@ def run(self):
progress_file_percentage = 0
progress_file_percentage_10 = 0
progress_transferred_size = '0'
progress_total_size = '0 Bytes'
progress_total_size = '0 B'
progress_speed = '-'
progress_speed_file = '-'
progress_eta = '-'
progress_size_percentage_10 = 0
regex_checked_files = r'Checks:\s+(\d+)\s+/\s+(\d+)'
regex_total_files = r'Transferred:\s+(\d+) / (\d+), (\d+)%(?:,\s*([\d.]+\sFiles/s))?'
regex_total_size = r'Transferred:[\s]+([\d.]+\s*[kMGTP]?) / ([\d.]+[\s]?[kMGTP]?Bytes),' \
r'\s*(?:\-|(\d+)\%),\s*([\d.]+\s*[kMGTP]?Bytes/s),\s*ETA\s*([\-0-9hmsdwy]+)'
regex_total_size = r'Transferred:[\s]+([\d.]+[\s]?[KMGTP]?B) / ([\d.]+[\s]?[KMGTP]?B),' \
r'\s*(?:\-|(\d+)\%),\s*([\d.]+\s*[KMGTP]?B/s),\s*ETA\s*([\-0-9hmsdwy]+)'
message_progress_last = ''
message_progress = ''
progress_update_time = datetime.datetime.now() - datetime.timedelta(minutes=5)
Expand Down Expand Up @@ -153,14 +153,12 @@ def run(self):
progress_checked_files = int(match_checked_files.group(1))
progress_total_check_files = int(match_checked_files.group(2))
progress_max_percentage_10 = max(progress_size_percentage_10, progress_file_percentage_10)
message_progress = '├──────⌈ Made with Love by Dr.Caduceus & MsGsuite⌋──────' \
'├ 🗂 Source : <a href="https://drive.google.com/open?id={}">{}</a>\n\n' \
'├ ✔️ Checks: <code>{} / {}</code>\n' \
'├ 📥 Transfers: <code>{} / {}</code>\n' \
message_progress = '├ 🗂 Source:<a href="https://drive.google.com/open?id={}">\n\n' \
'├ ✔️ Check:<code>{} / {}</code>\n' \
'├ ☑️ Transfer:<code>{} / {}</code>\n' \
'├ 📦 Size:<code>{} / {}</code>\n{}' \
'├ ⚡️Speed:<code>{}</code> \n├⏳ ETA: <code>{}</code>\n' \
'├ ⚡️ Speed:<code>{}</code> \n ⏳ ETA<code>{}</code>\n' \
'├ ⛩ Progress:[<code>{}</code>] {: >2}%\n\n' \
'├──────⌈ CloneBot V2🔥 ⌋──────' \
.format(
folder_id,
html.escape(destination_path),
Expand All @@ -180,7 +178,7 @@ def run(self):

match = re.search(r'Failed to Copy: Failed to Make Directory in the Destination', output)
if match:
message_progress = '{}\n│<code>Destination Write Permission Error.\n Please ensure that you have rights to upload files to the Destination.</code>'.format(message_progress)
message_progress = '{}\n\n<code> Write permission error</code>'.format(message_progress)
temp_message = '{}{}'.format(message, message_progress)
# logger.info('Write permission error, please confirm permission'.format())
try:
Expand All @@ -197,7 +195,7 @@ def run(self):

match = re.search(r"Couldn't List Directory", output)
if match:
message_progress = '{}\n│<code>Source Read permission Error. \n Please ensure that you have rights to read files from the Source Link</code>'.format(message_progress)
message_progress = '{}\n\n<code> Read permission error</code>'.format(message_progress)
temp_message = '{}{}'.format(message, message_progress)
# logger.info('Read permission error, please confirm the permission:')
try:
Expand Down Expand Up @@ -228,27 +226,27 @@ def run(self):
progress_update_time = datetime.datetime.now()

if self.critical_fault:
message_progress = '{}\n\n│ You have terminated the Cloning Process'.format(message_progress)
message_progress = '{}\n\n├ ❌ Process terminated'.format(message_progress)
process.terminate()
break

rc = process.poll()
message_progress_heading, message_progress_content = message_progress.split('\n', 1)
link_text = 'Unable to fetch Google Drive Link.'
message_progress_heading, message_progress_content = message_progress.split('', 1)
link_text = 'Unable to fetch drive link'
try:
link = gd.get_folder_link(dest_folder['folder_id'], destination_path)
if link:
link_text = '\n\n│ 👉 <a href="{}">Google Drive Link</a> 👈'.format(link)
link_text = '├ 🔗 Link:<a href="{}">Drive</a>'.format(link)
except Exception as e:
logger.info(str(e))

if self.critical_fault is True:
message = '{}{} ❌\n│{}\n│{}\n│'.format(message, message_progress_heading, message_progress_content,
link_text)
elif progress_file_percentage == 0 and progress_checked_files > 0:
message = '{}{}\n File Already Exists in the Destination!\n {}\n│'.format(message, message_progress_heading, link_text)
message = '{}{}\n\n├ ✅ File already exists in destination\n\n{}\n│'.format(message, message_progress_heading, link_text)
else:
message = '{}{}{}\n│{}\n│{}\n\n'.format(message,
message = '{}{}{}\n│{}\n│{}\n│'.format(message,
message_progress_heading,
'✅' if rc == 0 else '❌',
message_progress_content,
Expand All @@ -265,7 +263,9 @@ def run(self):
if self.critical_fault is True:
break

message += '\n╰──────⌈ ✅ Cloning Process Finished ! ✅ ⌋──────╯'
message += '\n├ 🔥 CloneBot V2'
'\n├ ©️ Made with ❤️ by Dr.Caduceus\n│'
'\n╰──────⌈ ✅ Finished ⌋──────╯'
try:
context.bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=message,
parse_mode=ParseMode.HTML, disable_web_page_preview=True)
Expand Down

0 comments on commit b61e94b

Please sign in to comment.