Esempio n. 1
0
 def onDownloadError(self, error):
     error = error.replace('<', ' ')
     error = error.replace('>', ' ')
     LOGGER.info(self.update.effective_chat.id)
     with download_dict_lock:
         try:
             download = download_dict[self.uid]
             del download_dict[self.uid]
             LOGGER.info(f"Deleting folder: {download.path()}")
             fs_utils.clean_download(download.path())
             LOGGER.info(str(download_dict))
         except Exception as e:
             LOGGER.error(str(e))
             pass
         count = len(download_dict)
     if self.message.from_user.username:
         uname = f"@{self.message.from_user.username}"
     else:
         uname = f'<a href="tg://user?id={self.message.from_user.id}">{self.message.from_user.first_name}</a>'
     msg = f"{uname} your download has been stopped due to: {error}"
     sendMessage(msg, self.bot, self.update)
     if count == 0:
         self.clean()
     else:
         update_all_messages()
Esempio n. 2
0
 def onUploadComplete(self, link: str, size):
     with download_dict_lock:
         msg = f'<b>๐Ÿ—‚ ๐—™๐—ถ๐—น๐—ฒ๐—ก๐—ฎ๐—บ๐—ฒ : </b><code>{download_dict[self.uid].name()}</code>\n<b>๐Ÿ“ฆ ๐“๐จ๐ญ๐š๐ฅ ๐’๐ข๐ณ๐ž : </b><code>{size}</code>\n' \
               f' \n' \
               f'๐Ÿ”…MXT MIRROR ZonE\n' \
               f' \n' \
               f'๐Ÿ”…๐™‚๐™ง๐™ค๐™ช๐™ฅ : @Mxtmirrorgroup\n'
         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
             buttons.buildbutton("๐Ÿ—‚ ๐ƒ๐ซ๐ข๐ฏ๐ž ๐‹๐ข๐ง๐ค ๐Ÿ—‚", surl)
         else:
             buttons.buildbutton("๐Ÿ—‚ ๐ƒ๐ซ๐ข๐ฏ๐ž ๐‹๐ข๐ง๐ค ๐Ÿ—‚", link)
         LOGGER.info(f'Done Uploading {download_dict[self.uid].name()}')
         if INDEX_URL is not None:
             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:
                 siurl = requests.get(
                     f'https://{SHORTENER}/api?api={SHORTENER_API}&url={share_url}&format=text'
                 ).text
                 buttons.buildbutton("๐Ÿš€ ๐ˆ๐ง๐๐ž๐ฑ ๐‹๐ข๐ง๐ค ๐Ÿš€", siurl)
             else:
                 buttons.buildbutton("๐Ÿš€ ๐ˆ๐ง๐๐ž๐ฑ ๐‹๐ข๐ง๐ค ๐Ÿš€", share_url)
         if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None:
             buttons.buildbutton(f"{BUTTON_THREE_NAME}",
                                 f"{BUTTON_THREE_URL}")
         if BUTTON_FOUR_NAME is not None and BUTTON_FOUR_URL is not None:
             buttons.buildbutton(f"{BUTTON_FOUR_NAME}",
                                 f"{BUTTON_FOUR_URL}")
         if BUTTON_FIVE_NAME is not None and BUTTON_FIVE_URL is not None:
             buttons.buildbutton(f"{BUTTON_FIVE_NAME}",
                                 f"{BUTTON_FIVE_URL}")
         if self.message.from_user.username:
             uname = f"@{self.message.from_user.username}"
         else:
             uname = f'<a href="tg://user?id={self.message.from_user.id}">{self.message.from_user.first_name}</a>'
         if uname is not None:
             msg += f'\n\n<b>๐Ÿ‘ค ๐—จ๐—ฝ๐—น๐—ผ๐—ฎ๐—ฑ๐—ฒ๐—ฟ : ๐Ÿ‘‰</b> {uname}\n\nโ–ซ๏ธ#Uploaded To Team Drive โœ“ \n\n๐Ÿšซ ๐˜ฟ๐™ค ๐™‰๐™ค๐™ฉ ๐™Ž๐™๐™–๐™ง๐™š ๐™„๐™ฃ๐™™๐™š๐™ญ ๐™‡๐™ž๐™ฃ๐™  \n\nโœ… ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ๐—ฒ๐—ฑ ๐—•๐˜† : <b>@ZEUTS</b>'
         try:
             fs_utils.clean_download(download_dict[self.uid].path())
         except FileNotFoundError:
             pass
         del download_dict[self.uid]
         count = len(download_dict)
     sendMarkup(msg, self.bot, self.update,
                InlineKeyboardMarkup(buttons.build_menu(2)))
     if count == 0:
         self.clean()
     else:
         update_all_messages()
Esempio n. 3
0
 def onUploadComplete(self, link: str, size):
     with download_dict_lock:
         msg = f'<b>๐Ÿ—‚ ๆ–‡ไปถๅ็งฐ : </b><code>{download_dict[self.uid].name()}</code>\n<b>๐Ÿ“ฆ ๆ€ป่ฎกๅฎน้‡ : </b><code>{size}</code>\n' \
               f' \n' \
               f'๐Ÿ”…่ฏถ๏ผŒ่ตท้ฃž๏ผ\n' \
               f' \n' \
               f'๐Ÿ”…ๅฐฑๆ˜ฏ้ฃž๏ผ\n'
         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
             buttons.buildbutton("๐Ÿ—‚ ๐ƒ๐ซ๐ข๐ฏ๐ž ้“พๆŽฅ ๐Ÿ—‚", surl)
         else:
             buttons.buildbutton("๐Ÿ—‚ ๐ƒ๐ซ๐ข๐ฏ๐ž ้“พๆŽฅ ๐Ÿ—‚", link)
         LOGGER.info(f'Done Uploading {download_dict[self.uid].name()}')
         if INDEX_URL is not None:
             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:
                 siurl = requests.get(
                     f'https://{SHORTENER}/api?api={SHORTENER_API}&url={share_url}&format=text'
                 ).text
                 buttons.buildbutton("๐Ÿš€ ๐ˆ๐ง๐๐ž๐ฑ ้“พๆŽฅ ๐Ÿš€", siurl)
             else:
                 buttons.buildbutton("๐Ÿš€ ๐ˆ๐ง๐๐ž๐ฑ ้“พๆŽฅ ๐Ÿš€", share_url)
         if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None:
             buttons.buildbutton(f"{BUTTON_THREE_NAME}",
                                 f"{BUTTON_THREE_URL}")
         if BUTTON_FOUR_NAME is not None and BUTTON_FOUR_URL is not None:
             buttons.buildbutton(f"{BUTTON_FOUR_NAME}",
                                 f"{BUTTON_FOUR_URL}")
         if BUTTON_FIVE_NAME is not None and BUTTON_FIVE_URL is not None:
             buttons.buildbutton(f"{BUTTON_FIVE_NAME}",
                                 f"{BUTTON_FIVE_URL}")
         if self.message.from_user.username:
             uname = f"@{self.message.from_user.username}"
         else:
             uname = f'<a href="tg://user?id={self.message.from_user.id}">{self.message.from_user.first_name}</a>'
         if uname is not None:
             msg += f'\n\n<b>๐Ÿ‘ค ไธŠไผ ่€… : ๐Ÿ‘‰</b> {uname}\n\nโ–ซ๏ธ#ไธŠไผ ๅˆฐๅ›ข้˜Ÿ็›˜ โœ“ \n\n๐Ÿšซ ไธๅˆ†ไบซ ๐™„๐™ฃ๐™™๐™š๐™ญ ้“พๆŽฅ \n\nโœ…ๆŠ€ๆœฏๆ”ฏๆŒ  : <b>@wawawame</b>'
         try:
             fs_utils.clean_download(download_dict[self.uid].path())
         except FileNotFoundError:
             pass
         del download_dict[self.uid]
         count = len(download_dict)
     sendMarkup(msg, self.bot, self.update,
                InlineKeyboardMarkup(buttons.build_menu(2)))
     if count == 0:
         self.clean()
     else:
         update_all_messages()
Esempio n. 4
0
 def onUploadError(self, error):
     e_str = error.replace('<', '').replace('>', '')
     with download_dict_lock:
         try:
             fs_utils.clean_download(download_dict[self.uid].path())
         except FileNotFoundError:
             pass
         del download_dict[self.message.message_id]
         count = len(download_dict)
     sendMessage(e_str, self.bot, self.update)
     if count == 0:
         self.clean()
     else:
         update_all_messages()
Esempio n. 5
0
 def onUploadComplete(self, link: str, size):
     with download_dict_lock:
         msg = f'<b>๐Ÿ—‚ ๐—™๐—ถ๐—น๐—ฒ๐—ก๐—ฎ๐—บ๐—ฒ : </b><code>{download_dict[self.uid].name()}</code>\n<b>๐“ฃ๐“ธ๐“ฝ๐“ช๐“ต ๐“ข๐“ฒ๐”ƒ๐“ฎ : </b><code>{size}</code>\n' \
               f' \n' \
               f'โ–€โ–„โ–€โ–„โ–€โ–„ ๐“‚ฯ‡โ“ฃ ็ˆช๐•€๐•ฃัแป–ล• ๐™ฯƒฮท๏ฝ… โ–„โ–€โ–„โ–€โ–„โ–€\n' \
               f' \n' \
               f'Group : @Zeuts\n'
         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
             buttons.buildbutton("๐•ฏ๐–—๐–Ž๐–›๐–Š ๐•ท๐–Ž๐–“๐–", surl)
         else:
             buttons.buildbutton("๐•ฏ๐–—๐–Ž๐–›๐–Š ๐•ท๐–Ž๐–“๐–", link)
         LOGGER.info(f'Done Uploading {download_dict[self.uid].name()}')
         if INDEX_URL is not None:
             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:
                 siurl = requests.get(f'https://{SHORTENER}/api?api={SHORTENER_API}&url={share_url}&format=text').text
                 buttons.buildbutton("๐“ฒ๐“ท๐“ญ๐“ฎ๐” ๐“ต๐“ฒ๐“ท๐“ด", siurl)
             else:
                 buttons.buildbutton("๐“ฒ๐“ท๐“ญ๐“ฎ๐” ๐“ต๐“ฒ๐“ท๐“ด", share_url)
         if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None:
             buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}")
         if BUTTON_FOUR_NAME is not None and BUTTON_FOUR_URL is not None:
             buttons.buildbutton(f"{BUTTON_FOUR_NAME}", f"{BUTTON_FOUR_URL}")
         if BUTTON_FIVE_NAME is not None and BUTTON_FIVE_URL is not None:
             buttons.buildbutton(f"{BUTTON_FIVE_NAME}", f"{BUTTON_FIVE_URL}")
         if self.message.from_user.username:
             uname = f"@{self.message.from_user.username}"
         else:
             uname = f'<a href="tg://user?id={self.message.from_user.id}">{self.message.from_user.first_name}</a>'
         if uname is not None:
             msg += f'\n\n<b> ๐–€๐–•๐–‘๐–”๐–†๐–‰๐–Š๐–— </b> {uname}\n\nโ–ซ๏ธ ๐–€๐–•๐–‘๐–”๐–†๐–‰๐–Š๐–‰ โœ“ \n\n ๐““๐“ธ๐“ท'๐“ฝ ๐“ข๐“ฑ๐“ช๐“ป๐“ฎ ๐“›๐“ฒ๐“ท๐“ด \n\nโœ… ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ๐—ฒ๐—ฑ ๐—•๐˜† : <b@zeuts</b>'
         try:
             fs_utils.clean_download(download_dict[self.uid].path())
         except FileNotFoundError:
             pass
         del download_dict[self.uid]
         count = len(download_dict)
     sendMarkup(msg, self.bot, self.update, InlineKeyboardMarkup(buttons.build_menu(2)))
     if count == 0:
         self.clean()
     else:
         update_all_messages()
Esempio n. 6
0
def cancel_mirror(update, context):
    args = update.message.text.split(" ", maxsplit=1)
    mirror_message = None
    if len(args) > 1:
        gid = args[1]
        dl = getDownloadByGid(gid)
        if not dl:
            sendMessage(f"GID: <code>{gid}</code> not found.", context.bot,
                        update)
            return
        with download_dict_lock:
            keys = list(download_dict.keys())
        mirror_message = dl.message
    elif update.message.reply_to_message:
        mirror_message = update.message.reply_to_message
        with download_dict_lock:
            keys = list(download_dict.keys())
            dl = download_dict[mirror_message.message_id]
    if len(args) == 1:
        if mirror_message is None or mirror_message.message_id not in keys:
            if BotCommands.MirrorCommand in update.message.text or \
               BotCommands.TarMirrorCommand in update.message.text or \
               BotCommands.UnzipMirrorCommand in update.message.text:
                msg = "Mirror Already Have Been Cancelled"
                sendMessage(msg, context.bot, update)
                return
            else:
                msg = "Please reply to the /mirror message which was used to start the download or /cancel gid to cancel it!"
                sendMessage(msg, context.bot, update)
                return
    if dl.status() == "Uploading...๐Ÿ“ค":
        sendMessage("Upload in Progress, You Can't Cancel It.", context.bot,
                    update)
        return
    elif dl.status() == "Archiving...๐Ÿ”":
        sendMessage("Archival in Progress, You Can't Cancel It.", context.bot,
                    update)
        return
    elif dl.status() == "Extracting...๐Ÿ“‚":
        sendMessage("Extract in Progress, You Can't Cancel It.", context.bot,
                    update)
        return
    else:
        dl.download().cancel_download()
    sleep(1)  # Wait a Second For Aria2 To free Resources.
    clean_download(f'{DOWNLOAD_DIR}{mirror_message.message_id}/')