Skip to content

Commit

Permalink
Final Design
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulkhatri137 committed Oct 6, 2021
1 parent f17fa2a commit 6d4ecce
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 41 deletions.
6 changes: 3 additions & 3 deletions bot/helper/mirror_utils/download_utils/telegram_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __download(self, message, path):
self.__onDownloadComplete()
else:
if not self.__is_cancelled:
self.__onDownloadError('Internal error occurred')
self.__onDownloadError('🚫Internal error occurred')

def add_download(self, message, path, filename):
_message = self.__user_bot.get_messages(message.chat.id, message.message_id)
Expand All @@ -100,9 +100,9 @@ def add_download(self, message, path, filename):
LOGGER.info(f'Downloading telegram file with id: {media.file_id}')
threading.Thread(target=self.__download, args=(_message, path)).start()
else:
self.__onDownloadError('File already being downloaded!')
self.__onDownloadError('💠File already being downloaded!')
else:
self.__onDownloadError('No document in the replied message')
self.__onDownloadError('No document in the replied message')

def cancel_download(self):
LOGGER.info(f'Cancelling download on user request: {self.gid}')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def __download(self, link):
self.__onDownloadComplete()
except ValueError:
LOGGER.info("Download Cancelled by User!")
self.onDownloadError("Download Cancelled by User!")
self.onDownloadError("🚫Download Cancelled by User!")

def add_download(self, link, path, qual, name):
pattern = r'^.*(youtu\.be\/|youtube.com\/)(playlist?)'
Expand Down
24 changes: 12 additions & 12 deletions bot/helper/mirror_utils/upload_utils/gdriveTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,18 @@ def deletefile(self, link: str):
try:
file_id = self.getIdFromUrl(link)
except (KeyError,IndexError):
msg = "Google drive ID could not be found in the provided link"
msg = "Google drive ID could not be found in the provided link"
return msg
msg = ''
try:
res = self.__service.files().delete(fileId=file_id, supportsTeamDrives=IS_TEAM_DRIVE).execute()
msg = "Successfully deleted"
msg = "Successfully deleted"
except HttpError as err:
LOGGER.error(str(err))
if "File not found" in str(err):
msg = "No such file exist"
msg = "No such file exist"
else:
msg = "Something went wrong check log"
msg = "Something went wrong check log"
finally:
return msg

Expand Down Expand Up @@ -314,7 +314,7 @@ def clone(self, link):
try:
file_id = self.getIdFromUrl(link)
except (KeyError,IndexError):
msg = "Google drive ID could not be found in the provided link"
msg = "Google drive ID could not be found in the provided link"
return msg, ""
msg = ""
LOGGER.info(f"File ID: {file_id}")
Expand All @@ -323,7 +323,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)
self.cloneFolder(meta.get('name'), meta.get('name'), meta.get('id'), dir_id)
msg += f'<b>Filename : </b><code>{meta.get("name")}</code>\n<b>Size : </b>{get_readable_file_size(self.transferred_size)}'
msg += f'<b>🗂 𝗙𝗶𝗹𝗲𝗡𝗮𝗺𝗲 : </b><code>{meta.get("name")}</code>\n<b>📦 𝐓𝐨𝐭𝐚𝐥 𝐒𝐢𝐳𝐞 : </b>{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:
Expand All @@ -347,7 +347,7 @@ def clone(self, link):
buttons.buildbutton(f"{BUTTON_FIVE_NAME}", f"{BUTTON_FIVE_URL}")
else:
file = self.copyFile(meta.get('id'), parent_id)
msg += f'<b>Filename : </b><code>{file.get("name")}</code>'
msg += f'<b>🗂 𝗙𝗶𝗹𝗲𝗡𝗮𝗺𝗲 : </b><code>{file.get("name")}</code>'
durl = self.__G_DRIVE_BASE_DOWNLOAD_URL.format(file.get("id"))
buttons = button_build.ButtonMaker()
if SHORTENER is not None and SHORTENER_API is not None:
Expand All @@ -356,7 +356,7 @@ def clone(self, link):
else:
buttons.buildbutton("☁️Drive Link☁️", durl)
try:
msg += f'\n<b>Size : </b><code>{get_readable_file_size(int(meta.get("size")))}</code>'
msg += f'\n<b>📦 𝐓𝐨𝐭𝐚𝐥 𝐒𝐢𝐳𝐞 : </b><code>{get_readable_file_size(int(meta.get("size")))}</code>'
except TypeError:
pass
if INDEX_URL is not None:
Expand Down Expand Up @@ -514,7 +514,7 @@ def drive_list(self, fileName):

content_count = 0
if response["files"]:
msg += f'<h4>Results : {fileName}</h4><br><br>'
msg += f'<h4>⚜️Search Results : {fileName}</h4>👇<br><br>'

for file in response.get('files', []):
if file.get('mimeType') == "application/vnd.google-apps.folder": # Detect Whether Current Entity is a Folder or File.
Expand Down Expand Up @@ -560,7 +560,7 @@ def drive_list(self, fileName):
self.telegraph_content.append(msg)

if len(self.telegraph_content) == 0:
return "No Result Found ❌:(", None
return "No such file exists:(", None

for content in self.telegraph_content :
self.path.append(Telegraph(access_token=telegraph_token).create_page(
Expand All @@ -574,9 +574,9 @@ def drive_list(self, fileName):
if self.num_of_path > 1:
self.edit_telegraph()

msg = f"<b>🔎Search Results For {fileName} </b>"
msg = f"<b>⚜️Search Results For {fileName} 👇</b>"
buttons = button_build.ButtonMaker()
buttons.buildbutton("HERE", f"https://telegra.ph/{self.path[0]}")
buttons.buildbutton("🔎Results", f"https://telegra.ph/{self.path[0]}")

return msg, InlineKeyboardMarkup(buttons.build_menu(1))

Expand Down
12 changes: 6 additions & 6 deletions bot/modules/cancel_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def cancel_mirror(update, context):
gid = args[1]
dl = getDownloadByGid(gid)
if not dl:
sendMessage(f"GID: <code>{gid}</code> not found.", context.bot, update)
sendMessage(f"GID: <code>{gid}</code> not found.", context.bot, update)
return
with download_dict_lock:
keys = list(download_dict.keys())
Expand All @@ -31,18 +31,18 @@ def cancel_mirror(update, context):
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:
msg = "Mirror already have been cancelled"
msg = "🚫Mirror already have been cancelled"
sendMessage(msg, context.bot, update)
return
else:
msg = f"Please reply to the <code>/{BotCommands.MirrorCommand}</code> message which was used to start the download or <code>/{BotCommands.CancelMirror} GID</code> to cancel it!"
msg = f"💠Please reply to the <code>/{BotCommands.MirrorCommand}</code> message which was used to start the download or <code>/{BotCommands.CancelMirror} GID</code> to cancel it!"
sendMessage(msg, context.bot, update)
return
if dl.status() == "Uploading":
sendMessage("Upload in Progress, Don't Cancel it.", context.bot, update)
sendMessage("🚫Upload in Progress, Don't Cancel it.", context.bot, update)
return
elif dl.status() == "Archiving":
sendMessage("Archival in Progress, Don't Cancel it.", context.bot, update)
sendMessage("🚫Archival in Progress, Don't Cancel it.", context.bot, update)
return
else:
dl.download().cancel_download()
Expand All @@ -59,7 +59,7 @@ def cancel_all(update, context):
dlDetails.download().cancel_download()
count += 1
delete_all_messages()
sendMessage(f'Cancelled {count} downloads!', context.bot, update)
sendMessage(f'🚫Cancelled {count} downloads!', context.bot, update)


cancel_mirror_handler = CommandHandler(BotCommands.CancelMirror, cancel_mirror,
Expand Down
4 changes: 2 additions & 2 deletions bot/modules/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def cloneNode(update,context):
args = update.message.text.split(" ",maxsplit=1)
if len(args) > 1:
link = args[1]
msg = sendMessage(f"Cloning: <code>{link}</code>",context.bot,update)
msg = sendMessage(f"⭕️Cloning: <code>{link}</code>",context.bot,update)
gd = GoogleDriveHelper()
result, button = gd.clone(link)
deleteMessage(context.bot,msg)
Expand All @@ -19,7 +19,7 @@ def cloneNode(update,context):
else:
sendMarkup(result,context.bot,update,button)
else:
sendMessage("Provide G-Drive Shareable Link to Clone.",context.bot,update)
sendMessage("Provide G-Drive Shareable Link to Clone.",context.bot,update)

clone_handler = CommandHandler(BotCommands.CloneCommand,cloneNode,filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True)
dispatcher.add_handler(clone_handler)
6 changes: 3 additions & 3 deletions bot/modules/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ def list_drive(update,context):
try:
search = update.message.text.split(' ',maxsplit=1)[1]
LOGGER.info(f"Searching: {search}")
reply = sendMessage('Searching..... Please wait!', context.bot, update)
reply = sendMessage('🔎Searching..... Please wait!', context.bot, update)
gdrive = GoogleDriveHelper(None)
msg, button = gdrive.drive_list(search)

if button:
editMessage(msg, reply, button)
else:
editMessage('No result found', reply, button)
editMessage('No result found', reply, button)

except IndexError:
sendMessage('send a search key along with command', context.bot, update)
sendMessage('🔶Send a search key along with command', context.bot, update)


list_handler = CommandHandler(BotCommands.ListCommand, list_drive,filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True)
Expand Down
8 changes: 4 additions & 4 deletions bot/modules/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def onDownloadError(self, error):
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}"
msg = f"{uname} your download has been stopped due to: {error}"
sendMessage(msg, self.bot, self.update)
if count == 0:
self.clean()
Expand Down Expand Up @@ -177,7 +177,7 @@ def onUploadComplete(self, link: str, size):
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'
msg += f'\n\n<b>👤 𝗨𝗽𝗹𝗼𝗮𝗱𝗲𝗿 👉</b> {uname}\n'
try:
fs_utils.clean_download(download_dict[self.uid].path())
except FileNotFoundError:
Expand Down Expand Up @@ -264,7 +264,7 @@ def _mirror(bot, update, isTar=False, extract=False):
else:
tag = None
if not bot_utils.is_url(link) and not bot_utils.is_magnet(link):
sendMessage('No download source provided', bot, update)
sendMessage('No download source provided', bot, update)
return

try:
Expand All @@ -277,7 +277,7 @@ def _mirror(bot, update, isTar=False, extract=False):
mega_dl.add_download(link, f'{DOWNLOAD_DIR}{listener.uid}/')
sendStatusMessage(update, bot)
elif bot_utils.is_mega_link(link) and BLOCK_MEGA_LINKS:
sendMessage("Mega links are blocked. Dont try to mirror mega links.", bot, update)
sendMessage("🚫Mega links are blocked. Dont try to mirror mega links.", bot, update)
else:
ariaDlManager.add_download(link, f'{DOWNLOAD_DIR}{listener.uid}/', listener, name)
sendStatusMessage(update, bot)
Expand Down
2 changes: 1 addition & 1 deletion bot/modules/mirror_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def mirror_status(update,context):
message = get_readable_message()
if len(message) == 0:
message = "No active downloads"
message = "No active downloads"
reply_message = sendMessage(message, context.bot, update)
threading.Thread(target=auto_delete_message, args=(bot, update.message, reply_message)).start()
return
Expand Down
2 changes: 1 addition & 1 deletion bot/modules/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def dyno_usage(update, context):
app = Heroku.app(HEROKU_APP_NAME)
else:
sendMessage(
"Please insert your HEROKU_APP_NAME and HEROKU_API_KEY in Vars",
"Please insert your HEROKU_APP_NAME and HEROKU_API_KEY in Vars",
context.bot,
update
)
Expand Down
10 changes: 5 additions & 5 deletions bot/modules/watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def _watch(bot: Bot, update, isTar=False):
try:
link = message_args[1]
except IndexError:
msg = f"/{BotCommands.WatchCommand} [yt_dl supported link] [quality] |[CustomName] to mirror with youtube_dl.\n\n"
msg += "<b>Note :- Quality and custom name are optional</b>\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 += f"\n\nExample :-\n<code>/{BotCommands.WatchCommand} https://youtu.be/ocX2FN1nguA 720 |My video bro</code>\n\n"
msg += "This file will be downloaded in 720p quality and it's name will be <b>My video bro</b>"
msg = f"⚜️/{BotCommands.WatchCommand} [yt_dl supported link] [quality] |[CustomName] to mirror with youtube_dl.\n\n"
msg += "<b>🔶Note :- Quality and custom name are optional</b>\n\nExample of quality :- audio, 144, 240, 360, 480, 720, 1080, 2160."
msg += "\n\n🔶If you want to use custom filename, plz enter it after |"
msg += f"\n\n💠Example :-\n<code>/{BotCommands.WatchCommand} https://youtu.be/ocX2FN1nguA 720 |Name</code>\n\n"
msg += "This file will be downloaded in 720p quality and it's name will be <b>Name</b>"
sendMessage(msg, bot, update)
return
try:
Expand Down
4 changes: 2 additions & 2 deletions config.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#Remove this line before deploying

# ENTER BOT TOKEN (Get your BOT_TOKEN by talking to @botfather)
BOT_TOKEN = ""
GDRIVE_FOLDER_ID = ""
Expand All @@ -12,10 +10,12 @@ AUTHORIZED_CHATS = "" #Separated by space
INDEX_URL = ""
IS_TEAM_DRIVE = ""
USE_SERVICE_ACCOUNTS = ""
# Mega
MEGA_KEY = ""
MEGA_USERNAME = ""
MEGA_PASSWORD = ""
BLOCK_MEGA_LINKS = "True"
# Others
STOP_DUPLICATE_MIRROR = "True"
MAX_TORRENT_SIZE = "20"
ENABLE_FILESIZE_LIMIT = "False"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ beautifulsoup4
google-api-python-client
google-auth-httplib2
google-auth-oauthlib
heroku3
js2py
lxml
megasdkrestclient
psutil
heroku3
Pyrogram
python-dotenv
python-magic
Expand Down

0 comments on commit 6d4ecce

Please sign in to comment.