From a077ecb66e4e8415ca2f22ffd61bdd7f7fcc35a6 Mon Sep 17 00:00:00 2001 From: Hafitz Setya <71178188+breakdowns@users.noreply.github.com> Date: Mon, 19 Apr 2021 03:34:31 +0700 Subject: [PATCH] v4.6.6 (#52) - direct_links: Added racaty.net support - Update support group link - Added img in /stats command - Fix Index URL encode problem - Added support for password protected index links by magneto - stickers: Added /remove command to remove sticker an existing pack Co-authored-by: The Fierce Warrior Co-authored-by: Dev Singh Rajput --- README.md | 10 ++++--- bot/__main__.py | 4 +-- .../download_utils/direct_link_generator.py | 18 +++++++++++++ .../mirror_utils/upload_utils/gdriveTools.py | 13 +++++++--- bot/modules/mirror.py | 19 +++++++++++--- bot/modules/stickers.py | 26 ++++++++++++++++--- 6 files changed, 74 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 611ff068d69..bba3f36e3c3 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,9 @@ This is a telegram bot writen in python for mirroring files on the internet to o - Delete files from drive - Shortener support - Custom Filename (Only for url, telegram files and ytdl. Not for mega links and magnet/torrents) -- Extracting password protected files and using custom filename see these examples: -> https://telegra.ph/Magneto-Python-Aria---Custom-Filename-Examples-01-20 +- Extracting password protected files, using custom filename and download from password protected index links see these examples: +

+ - Extract these filetypes and uploads to google drive ``` ZIP, RAR, TAR, 7z, ISO, WIM, CAB, GZIP, BZIP2, @@ -141,7 +142,7 @@ sudo docker run mirrorbot Fork this repo then upload **token.pickle** to your forks -**NOTE**: If you didn't upload **token.pickle**, uploading will not working. +**NOTE**: If you didn't upload **token.pickle**, uploading will not work.

## Deploying on Heroku using heroku-cli @@ -246,6 +247,9 @@ machine host login username password my_youtube_password ``` where host is the name of extractor (eg. youtube, twitch). Multiple accounts of different hosts can be added each separated by a new line +# Support Group +

+ # Credits Thanks to: diff --git a/bot/__main__.py b/bot/__main__.py index 1ac8dae142a..24ce9f420b6 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -38,7 +38,7 @@ def stats(update, context): f'CPU: {cpuUsage}%\n' \ f'RAM: {memory}%\n' \ f'Disk: {disk}%' - sendMessage(stats, context.bot, update) + update.effective_message.reply_photo("https://telegra.ph/file/db03910496f06094f1f7a.jpg", stats, parse_mode=ParseMode.HTML) @run_async @@ -60,7 +60,7 @@ def chat_list(update, context): def repo(update, context): bot.send_message(update.message.chat_id, reply_to_message_id=update.message.message_id, - text="Repo: https://github.com/breakdowns/slam-mirrorbot\nGroup: https://t.me/SlamMirrorSupportGroup", disable_web_page_preview=True) + text="Repo: https://github.com/breakdowns/slam-mirrorbot\nGroup: https://t.me/SlamMirrorSupport", disable_web_page_preview=True) @run_async diff --git a/bot/helper/mirror_utils/download_utils/direct_link_generator.py b/bot/helper/mirror_utils/download_utils/direct_link_generator.py index 9dabbcda615..9917f112b35 100644 --- a/bot/helper/mirror_utils/download_utils/direct_link_generator.py +++ b/bot/helper/mirror_utils/download_utils/direct_link_generator.py @@ -42,6 +42,8 @@ def direct_link_generator(link: str): return osdn(link) elif 'github.com' in link: return github(link) + elif 'racaty.net' in link: + return racaty(link) else: raise DirectDownloadLinkException(f'No Direct link function found for {link}') @@ -173,6 +175,22 @@ def github(url: str) -> str: raise DirectDownloadLinkException("`Error: Can't extract the link`\n") +def racaty(url: str) -> str: + dl_url = '' + try: + link = re.findall(r'\bhttps?://.*racaty\.net\S+', url)[0] + except IndexError: + raise DirectDownloadLinkException("`No Racaty links found`\n") + reqs=requests.get(link) + bss=BeautifulSoup(reqs.text,'html.parser') + op=bss.find('input',{'name':'op'})['value'] + id=bss.find('input',{'name':'id'})['value'] + rep=requests.post(link,data={'op':op,'id':id}) + bss2=BeautifulSoup(rep.text,'html.parser') + dl_url=bss2.find('a',{'id':'uniqueExpirylink'})['href'] + return dl_url + + def useragent(): """ useragent random setter diff --git a/bot/helper/mirror_utils/upload_utils/gdriveTools.py b/bot/helper/mirror_utils/upload_utils/gdriveTools.py index ba5bf0fffe4..19e06afbb7d 100644 --- a/bot/helper/mirror_utils/upload_utils/gdriveTools.py +++ b/bot/helper/mirror_utils/upload_utils/gdriveTools.py @@ -326,7 +326,8 @@ def clone(self, link): else: buttons.buildbutton("☁️Drive Link☁️", durl) if INDEX_URL is not None: - url = requests.utils.requote_uri(f'{INDEX_URL}/{meta.get("name")}/') + url_path = requests.utils.quote(f'{meta.get("name")}') + url = f'{INDEX_URL}/{url_path}/' if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text buttons.buildbutton("⚡Index Link⚡", siurl) @@ -353,7 +354,8 @@ def clone(self, link): except TypeError: pass if INDEX_URL is not None: - url = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}') + url_path = requests.utils.quote(f'{file.get("name")}') + url = f'{INDEX_URL}/{url_path}' if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text buttons.buildbutton("⚡Index Link⚡", siurl) @@ -515,12 +517,14 @@ def drive_list(self, fileName): else: msg += f"Drive Link" if INDEX_URL is not None: - url = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}/') + url_path = requests.utils.quote(f'{file.get("name")}') + url = f'{INDEX_URL}/{url_path}/' if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text msg += f' | Index Link' else: msg += f' | Index Link' + else: furl = f"https://drive.google.com/uc?id={file.get('id')}&export=download" msg += f"⁍{file.get('name')}
({get_readable_file_size(int(file.get('size')))})📄

" @@ -530,7 +534,8 @@ def drive_list(self, fileName): else: msg += f"Drive Link" if INDEX_URL is not None: - url = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}') + url_path = requests.utils.quote(f'{file.get("name")}') + url = f'{INDEX_URL}/{url_path}' if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text msg += f' | Index Link' diff --git a/bot/modules/mirror.py b/bot/modules/mirror.py index a7273cdf38b..9cc2120fdf9 100644 --- a/bot/modules/mirror.py +++ b/bot/modules/mirror.py @@ -20,6 +20,7 @@ from bot.helper.telegram_helper.filters import CustomFilters from bot.helper.telegram_helper.message_utils import * from bot.helper.telegram_helper import button_build +import urllib import pathlib import os import subprocess @@ -154,7 +155,8 @@ def onUploadComplete(self, link: str, size): buttons.buildbutton("☁️Drive Link☁️", link) LOGGER.info(f'Done Uploading {download_dict[self.uid].name()}') if INDEX_URL is not None: - share_url = requests.utils.requote_uri(f'{INDEX_URL}/{download_dict[self.uid].name()}') + url_path = requests.utils.quote(f'{download_dict[self.uid].name()}') + share_url = f'{INDEX_URL}/{url_path}' if os.path.isdir(f'{DOWNLOAD_DIR}/{self.uid}/{download_dict[self.uid].name()}'): share_url += '/' if SHORTENER is not None and SHORTENER_API is not None: @@ -202,10 +204,12 @@ def onUploadError(self, error): update_all_messages() def _mirror(bot, update, isTar=False, extract=False): - message_args = update.message.text.split(' ') - name_args = update.message.text.split('|') + mesg = update.message.text.split('\n') + message_args = mesg[0].split(' ') + name_args = mesg[0].split('|') try: link = message_args[1] + print(link) if link.startswith("|") or link.startswith("pswd: "): link = '' except IndexError: @@ -217,6 +221,15 @@ def _mirror(bot, update, isTar=False, extract=False): name = '' except IndexError: name = '' + try: + ussr = urllib.parse.quote(mesg[1], safe='') + pssw = urllib.parse.quote(mesg[2], safe='') + except: + ussr = '' + pssw = '' + if ussr != '' and pssw != '': + link = link.split("://", maxsplit=1) + link = f'{link[0]}://{ussr}:{pssw}@{link[1]}' pswd = re.search('(?<=pswd: )(.*)', update.message.text) if pswd is not None: pswd = pswd.groups() diff --git a/bot/modules/stickers.py b/bot/modules/stickers.py index b55d26174c8..40a1461dd75 100644 --- a/bot/modules/stickers.py +++ b/bot/modules/stickers.py @@ -355,6 +355,21 @@ def kang(update: Update, context: CallbackContext): os.remove("kangsticker.tgs") +@run_async +def delsticker(update, context): + msg = update.effective_message + if msg.reply_to_message and msg.reply_to_message.sticker: + file_id = msg.reply_to_message.sticker.file_id + context.bot.delete_sticker_from_set(file_id) + msg.reply_text( + "Deleted!" + ) + else: + update.effective_message.reply_text( + "Please reply to sticker message to del sticker" + ) + + def makepack_internal( update, context, @@ -426,16 +441,18 @@ def makepack_internal( @run_async def stickhelp(update, context): help_string = ''' -• `/stickerid`*:* reply to a sticker to me to tell you its file ID. -• `/getsticker`*:* reply to a sticker to me to upload its raw PNG file. -• `/kang`*:* reply to a sticker to add it to your pack. -• `/stickers`*:* Find stickers for given term on combot sticker catalogue +• `/stickerid`*:* Reply to a sticker to me to tell you its file ID. +• `/getsticker`*:* Reply to a sticker to me to upload its raw PNG file. +• `/kang`*:* Reply to a sticker to add it to your pack. +• `/remove`*:* Replay to a sticker to remove sticker from an existing pack. +• `/stickers`*:* Find stickers for given term on combot sticker catalogue. ''' update.effective_message.reply_photo("https://telegra.ph/file/db03910496f06094f1f7a.jpg", help_string, parse_mode=ParseMode.MARKDOWN) STICKERID_HANDLER = CommandHandler("stickerid", stickerid) GETSTICKER_HANDLER = CommandHandler("getsticker", getsticker) KANG_HANDLER = CommandHandler("kang", kang) +DEL_HANDLER = CommandHandler("remove", delsticker) STICKERS_HANDLER = CommandHandler("stickers", cb_sticker) STICKHELP_HANDLER = CommandHandler("stickerhelp", stickhelp) @@ -444,4 +461,5 @@ def stickhelp(update, context): dispatcher.add_handler(STICKERID_HANDLER) dispatcher.add_handler(GETSTICKER_HANDLER) dispatcher.add_handler(KANG_HANDLER) +dispatcher.add_handler(DEL_HANDLER) dispatcher.add_handler(STICKHELP_HANDLER)