From 174d96b4d4f1b38eafaab5cda1ad142a182b8632 Mon Sep 17 00:00:00 2001
From: Hafitz Setya <71178188+breakdowns@users.noreply.github.com>
Date: Mon, 5 Apr 2021 18:22:25 +0700
Subject: [PATCH] v4.6.1 (#41)
- Tidying up
---
bot/__init__.py | 3 ++-
bot/__main__.py | 2 +-
bot/helper/mirror_utils/download_utils/aria2_download.py | 2 +-
bot/helper/mirror_utils/upload_utils/gdriveTools.py | 8 ++++----
4 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/bot/__init__.py b/bot/__init__.py
index 5454313e88d..c9a49fc39f9 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -107,10 +107,11 @@ def getConfig(name: str):
if USE_TELEGRAPH:
sname = ''.join(random.SystemRandom().choices(string.ascii_letters, k=8))
LOGGER.info("Using Telegra.ph")
- LOGGER.info("Generating TELEGRAPH_TOKEN")
+ LOGGER.info("Generating TELEGRAPH_TOKEN using '" + sname + "' name")
telegraph = Telegraph()
telegraph.create_account(short_name=sname)
TELEGRAPH_TOKEN = telegraph.get_access_token()
+ LOGGER.info("Telegraph Token Generated: '" + TELEGRAPH_TOKEN + "'")
if not USE_TELEGRAPH:
TELEGRAPH_TOKEN = None
LOGGER.info("Not Using Telegra.ph")
diff --git a/bot/__main__.py b/bot/__main__.py
index 48c44a3f2d4..13294e129d4 100644
--- a/bot/__main__.py
+++ b/bot/__main__.py
@@ -44,7 +44,7 @@ def stats(update, context):
@run_async
def start(update, context):
start_string = f'''
-Hi {update.message.chat.first_name}, This bot can mirror all your links to Google drive!
+This bot can mirror all your links to Google drive!
Type /{BotCommands.HelpCommand} to get a list of available commands
'''
update.effective_message.reply_photo("https://telegra.ph/file/db03910496f06094f1f7a.jpg", start_string, parse_mode=ParseMode.MARKDOWN)
diff --git a/bot/helper/mirror_utils/download_utils/aria2_download.py b/bot/helper/mirror_utils/download_utils/aria2_download.py
index 07fa91046ed..d9e37923392 100644
--- a/bot/helper/mirror_utils/download_utils/aria2_download.py
+++ b/bot/helper/mirror_utils/download_utils/aria2_download.py
@@ -26,7 +26,7 @@ def __onDownloadStarted(self, api, gid):
smsg, button = gdrive.drive_list(sname)
if STOP_DUPLICATE_MIRROR:
if smsg:
- dl.getListener().onDownloadError(f'File is already available in drive.\n\n')
+ dl.getListener().onDownloadError(f'π‘ File is already available in drive. You should have search before mirror any file. You might get ban if you do this again. This download has been stopped.\n\n')
print(dl.getListener())
if button:
sendMarkup("Here are the search results:π\n", dl.getListener().bot, dl.getListener().update, button)
diff --git a/bot/helper/mirror_utils/upload_utils/gdriveTools.py b/bot/helper/mirror_utils/upload_utils/gdriveTools.py
index 595c7dddef1..37d972260bd 100644
--- a/bot/helper/mirror_utils/upload_utils/gdriveTools.py
+++ b/bot/helper/mirror_utils/upload_utils/gdriveTools.py
@@ -151,7 +151,7 @@ def upload_file(self, file_path, file_name, mime_type, parent_id):
# File body description
file_metadata = {
'name': file_name,
- 'description': 'mirror',
+ 'description': 'Uploaded by Slam Mirror Bot',
'mimeType': mime_type,
}
if parent_id is not None:
@@ -317,7 +317,7 @@ def clone(self, link):
if meta.get("mimeType") == self.__G_DRIVE_DIR_MIME_TYPE:
dir_id = self.create_directory(meta.get('name'), parent_id)
result = self.cloneFolder(meta.get('name'), meta.get('name'), meta.get('id'), dir_id)
- msg += f'Filename: {meta.get("name")}
\nSize: {get_readable_file_size(self.transferred_size)}'
+ msg += f'Filename: {meta.get("name")}
\nSize: {get_readable_file_size(self.transferred_size)}
'
durl = self.__G_DRIVE_DIR_BASE_DOWNLOAD_URL.format(dir_id)
buttons = button_build.ButtonMaker()
if SHORTENER is not None and SHORTENER_API is not None:
@@ -478,7 +478,7 @@ def edit_telegraph(self):
content += f' | Next'
nxt_page += 1
Telegraph(access_token=TELEGRAPH_TOKEN).edit_page(path = self.path[prev_page],
- title = 'Slam Mirror Bot Search',
+ title = 'Slam Mirror Bot - Search',
author_name='Slam Mirror Bot',
author_url='https://github.com/breakdowns/slam-mirrorbot',
html_content=content)
@@ -510,7 +510,7 @@ def drive_list(self, fileName):
if file.get(
'mimeType') == "application/vnd.google-apps.folder": # Detect Whether Current Entity is a Folder or File.
furl = f"https://drive.google.com/drive/folders/{file.get('id')}"
- msg += f"β{file.get('name')}
(folderπ)
"
+ msg += f"β{file.get('name')}
(folder)π
"
if SHORTENER is not None and SHORTENER_API is not None:
sfurl = requests.get(
'https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, furl)).text