From ea8e2299ecaf46f9a4bf8164ada04e315a423fba Mon Sep 17 00:00:00 2001 From: Hafitz Setya <71178188+breakdowns@users.noreply.github.com> Date: Tue, 8 Jun 2021 06:38:26 +0700 Subject: [PATCH] Tidying up & Add credits for Anas --- README.md | 11 ++++++---- app.json | 6 +++++- bot/__init__.py | 3 +-- bot/__main__.py | 4 ++-- .../mirror_utils/upload_utils/gdriveTools.py | 20 +++++++++---------- bot/modules/clone.py | 2 +- bot/modules/mirror.py | 8 ++++---- bot/modules/watch.py | 2 +- config_sample.env | 2 +- 9 files changed, 32 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index cb8b734..c2297c6 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,10 @@ # Features supported: ## Additional Features -- Get detailed info about replied media +- Get detailed info about replied media (Only for Telegram file) - Nyaa.si and Sukebei Torrent search - Speedtest with picture results +- Limiting cloning Google Drive support - Limiting Torrent size support - Sudo with Database support - Multiple Trackers support @@ -31,13 +32,13 @@ - View Link button (Not all Index support, recommended using [Bhadoo Index](https://github.com/ParveenBhadooOfficial/Google-Drive-Index)) - Direct links supported: ``` -Racaty, Hxfile, Anonfiles, Femax20, Layarkacaxxi, -Onedrive (Only works for file not folder and busines) +Racaty, Hxfile, Anonfiles, Fembed, Femax20, Layarkacaxxi, +Uptobox (Uptobox account must be premium), +Onedrive (Only works for file not folder or busines account) ``` ## From Original Repos - Mirroring direct download links, Torrent, and Telegram files to Google Drive - Mirroring Mega.nz links to Google Drive (If your Mega account not premium, it will limit 4-5gb/day) -- Mirroring Uptobox.com links to Google Drive (Uptobox account must be premium) - Copy files from someone's Drive to your Drive (Using Autorclone) - Download/Upload progress, Speeds and ETAs - Mirror all Youtube-dl supported links @@ -138,6 +139,7 @@ Fill up rest of the fields. Meaning of each fields are discussed below: - **BLOCK_MEGA_FOLDER**: (Optional field) If you want to remove mega.nz folder support, set it to `True`. - **BLOCK_MEGA_LINKS**: (Optional field) If you want to remove mega.nz mirror support, set it to `True`. - **STOP_DUPLICATE_MIRROR**: (Optional field) (Leave empty if unsure) if this field is set to `True`, bot will check file in drive, if it is present in Drive, downloading will be stopped. (**Note**: File will be checked using filename, not using filehash, so this feature is not perfect yet) +- **CLONE_LIMIT**: To limit cloning Google Drive (leave space between number and unit (tb or gb only)), examples: if you fill `1 gb` it will limit `1gb`. - **ENABLE_FILESIZE_LIMIT**: Set it to `True` if you want to use `MAX_TORRENT_SIZE`. - **MAX_TORRENT_SIZE**: To limit the Torrent mirror size, Fill The amount you want to limit, examples: if you fill `15` it will limit `15gb`. - **IMAGE_URL**: (Optional field) Show Image/Logo in /start message. Fill value of image your link image, use telegra.ph or any direct link image. @@ -289,5 +291,6 @@ Thanks to: - [Dank-del](https://github.com/Dank-del/) for base repo - [magneto261290](https://github.com/magneto261290/) for some features - [SVR666](https://github.com/SVR666/) for some features & fixes +- [anasty17](https://github.com/anasty17) for some features & help And many more people who aren't mentioned here, but may be found in [Contributors](https://github.com/breakdowns/slam-mirrorbot/graphs/contributors). diff --git a/app.json b/app.json index 72c8a61..af49451 100644 --- a/app.json +++ b/app.json @@ -104,10 +104,14 @@ "required": false }, "MAX_TORRENT_SIZE": { - "description": "To limit the torrent mirror size, Fill The amount you want to limit, examples: if you fill 15 it will limit 15gb.", + "description": "To limit the Torrent mirror size, Fill The amount you want to limit, examples: if you fill 15 it will limit 15gb.", "value": "15", "required": false }, + "CLONE_LIMIT": { + "description": "To limit cloning Google Drive (leave space between number and unit (tb or gb only)), examples: if you fill 1 gb it will limit 1gb.", + "required": false + }, "STOP_DUPLICATE_MIRROR": { "description": "If this field is set to True, bot will check file in drive, if it is present in drive, downloading will be stopped.", "required": false diff --git a/bot/__init__.py b/bot/__init__.py index de3244f..d9e5c15 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -129,11 +129,10 @@ app = Client(':memory:', api_id=int(TELEGRAM_API), api_hash=TELEGRAM_HASH, bot_t #Generate Telegraph Token sname = ''.join(random.SystemRandom().choices(string.ascii_letters, k=8)) -LOGGER.info("Generating Telegraph Token using '" + sname + "' name") +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 + "'") try: MEGA_API_KEY = getConfig('MEGA_API_KEY') diff --git a/bot/__main__.py b/bot/__main__.py index 35b4548..c80e1cb 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -141,7 +141,7 @@ def bot_help(update, context): /shell: Run commands in Shell (Terminal). -/mediainfo: Get detailed info about replied media. +/mediainfo: Get detailed info about replied media (Only for Telegram file). /tshelp: Get help for Torrent search module. @@ -177,7 +177,7 @@ def bot_help(update, context): /{BotCommands.SpeedCommand}: Check Internet Speed of the Host -/mediainfo: Get detailed info about replied media. +/mediainfo: Get detailed info about replied media (Only for Telegram file). /tshelp: Get help for Torrent search module. diff --git a/bot/helper/mirror_utils/upload_utils/gdriveTools.py b/bot/helper/mirror_utils/upload_utils/gdriveTools.py index 9052579..945e20e 100644 --- a/bot/helper/mirror_utils/upload_utils/gdriveTools.py +++ b/bot/helper/mirror_utils/upload_utils/gdriveTools.py @@ -332,9 +332,9 @@ class GoogleDriveHelper: 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'\nType: Folder' - msg += f'\nSubFolders: {self.total_folders}' - msg += f'\nFiles: {self.total_files}' + msg += f'\nType: Folder' + msg += f'\nSubFolders: {self.total_folders}' + msg += f'\nFiles: {self.total_files}' 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: @@ -372,7 +372,7 @@ class GoogleDriveHelper: typeee = 'File' try: msg += f'\nSize: {get_readable_file_size(int(meta.get("size")))}' - msg += f'\nType: {typeee}' + msg += f'\nType: {typeee}' except TypeError: pass if INDEX_URL is not None: @@ -630,10 +630,10 @@ class GoogleDriveHelper: if drive_file['mimeType'] == self.__G_DRIVE_DIR_MIME_TYPE: self.gDrive_directory(**drive_file) msg += f'Filename: {name}' - msg += f'\nSize: {get_readable_file_size(self.total_bytes)}' - msg += f'\nType: Folder' - msg += f'\nSubFolders: {self.total_folders}' - msg += f'\nFiles: {self.total_files}' + msg += f'\nSize: {get_readable_file_size(self.total_bytes)}' + msg += f'\nType: Folder' + msg += f'\nSubFolders: {self.total_folders}' + msg += f'\nFiles: {self.total_files}' clonesizelimit = self.total_bytes else: msg += f'Filename: {name}' @@ -645,8 +645,8 @@ class GoogleDriveHelper: self.total_files += 1 self.gDrive_file(**drive_file) msg += f'\nSize: {get_readable_file_size(self.total_bytes)}' - msg += f'\nType: {typee}' - msg += f'\nFiles: {self.total_files}' + msg += f'\nType: {typee}' + msg += f'\nFiles: {self.total_files}' clonesizelimit = self.total_bytes except TypeError: pass diff --git a/bot/modules/clone.py b/bot/modules/clone.py index 2006fba..5955ff9 100644 --- a/bot/modules/clone.py +++ b/bot/modules/clone.py @@ -19,7 +19,7 @@ def cloneNode(update, context): limitint = int(limit[0]) res, clonesizelimit = gd.count(link) if clonesizelimit != "": - msgg = f'Failed, clone limit is {CLONE_LIMIT}' + msgg = f'Failed, Clone limit is {CLONE_LIMIT}' if 'GB' in limit or 'gb' in limit: if clonesizelimit > limitint * 1024**3: deleteMessage(context.bot, mssg) diff --git a/bot/modules/mirror.py b/bot/modules/mirror.py index 5347af7..731a8e1 100644 --- a/bot/modules/mirror.py +++ b/bot/modules/mirror.py @@ -150,11 +150,11 @@ class MirrorListener(listeners.MirrorListeners): with download_dict_lock: msg = f'Filename: {download_dict[self.uid].name()}\nSize: {size}' if os.path.isdir(f'{DOWNLOAD_DIR}/{self.uid}/{download_dict[self.uid].name()}'): - msg += '\nType: Folder' - msg += f'\nSubFolders: {folders}' - msg += f'\nFiles: {files}' + msg += '\nType: Folder' + msg += f'\nSubFolders: {folders}' + msg += f'\nFiles: {files}' else: - msg += f'\nType: {typ}' + msg += f'\nType: {typ}' buttons = button_build.ButtonMaker() if SHORTENER is not None and SHORTENER_API is not None: surl = requests.get(f'https://{SHORTENER}/api?api={SHORTENER_API}&url={link}&format=text').text diff --git a/bot/modules/watch.py b/bot/modules/watch.py index 6a1c462..e267fa8 100644 --- a/bot/modules/watch.py +++ b/bot/modules/watch.py @@ -19,7 +19,7 @@ def _watch(bot: Bot, update, isTar=False): except IndexError: msg = f"/{BotCommands.WatchCommand} [youtube-dl supported link] [quality] |[CustomName] to mirror with youtube-dl.\n\n" msg += "Note: Quality and custom name are optional\n\nExample of quality: audio, 144, 240, 360, 480, 720, 1080, 2160." - msg += "\n\nIf you want to use custom filename, plz enter it after |" + msg += "\n\nIf you want to use custom filename, enter it after |" msg += f"\n\nExample:\n/{BotCommands.WatchCommand} https://youtu.be/Pk_TthHfLeE 720 |Slam\n\n" msg += "This file will be downloaded in 720p quality and it's name will be Slam" sendMessage(msg, bot, update) diff --git a/config_sample.env b/config_sample.env index ca936e7..1bfb282 100644 --- a/config_sample.env +++ b/config_sample.env @@ -33,7 +33,7 @@ MAX_TORRENT_SIZE = 15 # Fill only if you deploying with heroku-cli and Goorm IDE HEROKU_API_KEY = "" HEROKU_APP_NAME = "" -# Add more buttons (Three buttons are already added of file link and index link, you can add extra buttons too, these are optional) +# Add more buttons (Three buttons are already added of Drive Link, Index Link, and View Link, you can add extra buttons too, these are optional) # If you don't know what are below entries, simply leave them, Don't fill anything in them. BUTTON_FOUR_NAME = "" BUTTON_FOUR_URL = ""