-fix tg download for media sent by bot
-fix auth for sudo users while not using database

Signed-off-by: anas <e.anastayyar@gmail.com>
This commit is contained in:
anas 2021-07-18 00:47:59 +03:00
parent 7944a8c672
commit 232538ee03
3 changed files with 15 additions and 2 deletions

View File

@ -82,7 +82,7 @@ class TelegramDownloadHelper(DownloadHelper):
self.__onDownloadError('Internal error occurred')
def add_download(self, message, path, filename):
_message = self._bot.get_messages(message.chat.id, message.message_id)
_message = self._bot.get_messages(message.chat.id, reply_to_message_ids=message.message_id)
media = None
media_array = [_message.document, _message.video, _message.audio]
for i in media_array:

View File

@ -112,6 +112,9 @@ def addSudo(update, context):
if DB_URI is not None:
msg = DbManger().db_addsudo(user_id)
else:
with open('authorized_chats.txt', 'a') as file:
file.write(f'{user_id}\n')
AUTHORIZED_CHATS.add(user_id)
with open('sudo_users.txt', 'a') as file:
file.write(f'{user_id}\n')
SUDO_USERS.add(user_id)
@ -128,6 +131,9 @@ def addSudo(update, context):
if DB_URI is not None:
msg = DbManger().db_addsudo(user_id)
else:
with open('authorized_chats.txt', 'a') as file:
file.write(f'{user_id}\n')
AUTHORIZED_CHATS.add(user_id)
with open('sudo_users.txt', 'a') as file:
file.write(f'{user_id}\n')
SUDO_USERS.add(user_id)
@ -148,6 +154,7 @@ def removeSudo(update, context):
if DB_URI is not None:
msg = DbManger().db_rmsudo(user_id)
else:
AUTHORIZED_CHATS.remove(user_id)
SUDO_USERS.remove(user_id)
msg = 'Demoted'
else:
@ -161,11 +168,16 @@ def removeSudo(update, context):
if DB_URI is not None:
msg = DbManger().db_rmsudo(user_id)
else:
AUTHORIZED_CHATS.remove(user_id)
SUDO_USERS.remove(user_id)
msg = 'Demoted'
else:
msg = 'Not a Sudo'
if DB_URI is None:
with open('authorized_chats.txt', 'a') as file:
file.truncate(0)
for i in AUTHORIZED_CHATS:
file.write(f'{i}\n')
with open('sudo_users.txt', 'a') as file:
file.truncate(0)
for i in SUDO_USERS:

View File

@ -272,7 +272,8 @@ def _mirror(bot, update, isTar=False, extract=False):
if file.mime_type != "application/x-bittorrent":
listener = MirrorListener(bot, update, pswd, isTar, tag, extract)
tg_downloader = TelegramDownloadHelper(listener)
tg_downloader.add_download(reply_to, f'{DOWNLOAD_DIR}{listener.uid}/', name)
ms = update.message
tg_downloader.add_download(ms, f'{DOWNLOAD_DIR}{listener.uid}/', name)
if len(Interval) == 0:
Interval.append(setInterval(DOWNLOAD_STATUS_UPDATE_INTERVAL, update_all_messages))
return