HTML bosku

This commit is contained in:
FA Tulloh 2021-07-08 03:49:25 +08:00 committed by GitHub
parent 00fb002f82
commit c0bfd3cfc0
Signed by untrusted user: GitHub
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,14 @@
import requests
from telegram.ext import CommandHandler
from telegram.error import BadRequest
from telegram import InlineKeyboardMarkup
from bot import Interval, INDEX_URL, BUTTON_FOUR_NAME, BUTTON_FOUR_URL, BUTTON_FIVE_NAME, BUTTON_FIVE_URL, BUTTON_SIX_NAME, BUTTON_SIX_URL, BLOCK_MEGA_FOLDER, BLOCK_MEGA_LINKS, VIEW_LINK
from bot import dispatcher, DOWNLOAD_DIR, DOWNLOAD_STATUS_UPDATE_INTERVAL, download_dict, download_dict_lock, SHORTENER, SHORTENER_API, TAR_UNZIP_LIMIT
from bot import(
Interval, INDEX_URL, BUTTON_FOUR_NAME, BUTTON_FOUR_URL, BUTTON_FIVE_NAME, BUTTON_FIVE_URL,
BUTTON_SIX_NAME, BUTTON_SIX_URL, BLOCK_MEGA_FOLDER, BLOCK_MEGA_LINKS, VIEW_LINK,
dispatcher, DOWNLOAD_DIR, DOWNLOAD_STATUS_UPDATE_INTERVAL, download_dict, download_dict_lock,
SHORTENER, SHORTENER_API, TAR_UNZIP_LIMIT
)
from bot.helper.ext_utils import fs_utils, bot_utils
from bot.helper.ext_utils.bot_utils import setInterval, get_mega_link_type
from bot.helper.ext_utils.exceptions import DirectDownloadLinkException, NotSupportedExtractionArchive
@ -202,7 +207,10 @@ class MirrorListener(listeners.MirrorListeners):
pass
del download_dict[self.uid]
count = len(download_dict)
sendMarkup(msg, self.bot, self.update, InlineKeyboardMarkup(buttons.build_menu(2)))
try:
sendMarkup(msg, self.bot, self.update, InlineKeyboardMarkup(buttons.build_menu(2)))
except BadRequest as e:
LOGGER.warning(e.message)
if count == 0:
self.clean()
else:
@ -340,6 +348,14 @@ def _mirror(bot, update, isTar=False, extract=False):
mega_dl = MegaDownloadHelper()
mega_dl.add_download(link, f'{DOWNLOAD_DIR}/{listener.uid}/', listener)
else:
if link.startswith("https"):
resp = requests.head(link, allow_redirects=True)
if resp.headers["content-type"].startswith("text/html") and not resp.url.endswith(".torrent"):
sendMessage(
"Provided link returned to a webpage, download aborted.",
bot, update
)
return
ariaDlManager.add_download(link, f'{DOWNLOAD_DIR}/{listener.uid}/', listener, name)
sendStatusMessage(update, bot)
if len(Interval) == 0:
@ -358,12 +374,24 @@ def unzip_mirror(update, context):
_mirror(context.bot, update, extract=True)
mirror_handler = CommandHandler(BotCommands.MirrorCommand, mirror,
filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True)
tar_mirror_handler = CommandHandler(BotCommands.TarMirrorCommand, tar_mirror,
filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True)
unzip_mirror_handler = CommandHandler(BotCommands.UnzipMirrorCommand, unzip_mirror,
filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True)
mirror_handler = CommandHandler(
BotCommands.MirrorCommand,
mirror,
filters = CustomFilters.authorized_chat | CustomFilters.authorized_user,
run_async = True
)
tar_mirror_handler = CommandHandler(
BotCommands.TarMirrorCommand,
tar_mirror,
filters = CustomFilters.authorized_chat | CustomFilters.authorized_user,
run_async = True
)
unzip_mirror_handler = CommandHandler(
BotCommands.UnzipMirrorCommand,
unzip_mirror,
filters = CustomFilters.authorized_chat | CustomFilters.authorized_user,
run_async = True
)
dispatcher.add_handler(mirror_handler)
dispatcher.add_handler(tar_mirror_handler)
dispatcher.add_handler(unzip_mirror_handler)