Expose message object from Status objects
Signed-off-by: lzzy12 <jhashivam2020@gmail.com>
This commit is contained in:
parent
b58eb87b11
commit
0536472e28
|
|
@ -61,7 +61,7 @@ def get_readable_file_size(size_in_bytes) -> str:
|
|||
def getDownloadByGid(gid):
|
||||
with download_dict_lock:
|
||||
for dl in download_dict.values():
|
||||
if dl.status() == MirrorStatus.STATUS_DOWNLOADING:
|
||||
if dl.status() == MirrorStatus.STATUS_DOWNLOADING or dl.status() == MirrorStatus.STATUS_WAITING:
|
||||
if dl.gid() == gid:
|
||||
return dl
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class AriaDownloadHelper(DownloadHelper):
|
|||
self.gid = api.get_download(gid).followed_by_ids[0]
|
||||
with download_dict_lock:
|
||||
download_dict[self.__listener.uid] = AriaDownloadStatus(self.gid, self.__listener)
|
||||
download_dict[self.__listener.uid].is_torrent =True
|
||||
download_dict[self.__listener.uid].is_torrent = True
|
||||
update_all_messages()
|
||||
LOGGER.info(f'Changed gid from {gid} to {self.gid}')
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class TelegramDownloadHelper(DownloadHelper):
|
|||
|
||||
def __onDownloadStart(self, name, size, file_id):
|
||||
with download_dict_lock:
|
||||
download_dict[self.__listener.uid] = TelegramDownloadStatus(self, self.__listener.uid)
|
||||
download_dict[self.__listener.uid] = TelegramDownloadStatus(self, self.__listener)
|
||||
with global_lock:
|
||||
GLOBAL_GID.add(file_id)
|
||||
with self.__resource_lock:
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class YoutubeDLHelper(DownloadHelper):
|
|||
|
||||
def __onDownloadStart(self):
|
||||
with download_dict_lock:
|
||||
download_dict[self.__listener.uid] = YoutubeDLDownloadStatus(self, self.__listener.uid)
|
||||
download_dict[self.__listener.uid] = YoutubeDLDownloadStatus(self, self.__listener)
|
||||
|
||||
def __onDownloadComplete(self):
|
||||
self.__listener.onDownloadComplete()
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ class AriaDownloadStatus(Status):
|
|||
self.__gid = gid
|
||||
self.__download = get_download(gid)
|
||||
self.__uid = listener.uid
|
||||
self._listener = listener
|
||||
self.__listener = listener
|
||||
self.message = listener.message
|
||||
self.last = None
|
||||
self.is_waiting = False
|
||||
|
||||
|
|
@ -64,7 +65,7 @@ class AriaDownloadStatus(Status):
|
|||
status = MirrorStatus.STATUS_CANCELLED
|
||||
elif download.has_failed:
|
||||
status = MirrorStatus.STATUS_FAILED
|
||||
self._listener.onDownloadError('Unknown Error')
|
||||
self.__listener.onDownloadError('Unknown Error')
|
||||
else:
|
||||
status = MirrorStatus.STATUS_DOWNLOADING
|
||||
return status
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ from .status import Status
|
|||
|
||||
|
||||
class TelegramDownloadStatus(Status):
|
||||
def __init__(self, obj, uid):
|
||||
def __init__(self, obj, listener):
|
||||
self.obj = obj
|
||||
self.uid = uid
|
||||
self.uid = listener.uid
|
||||
self.message = listener.message
|
||||
|
||||
def gid(self):
|
||||
return self.obj.gid
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@ from bot import DOWNLOAD_DIR
|
|||
|
||||
|
||||
class UploadStatus(Status):
|
||||
def __init__(self, obj, size, uid):
|
||||
def __init__(self, obj, size, listener):
|
||||
self.obj = obj
|
||||
self.__size = size
|
||||
self.uid = uid
|
||||
self.uid = listener.uid
|
||||
self.message = listener.message
|
||||
|
||||
def path(self):
|
||||
return f"{DOWNLOAD_DIR}{self.uid}"
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ from .status import Status
|
|||
|
||||
|
||||
class YoutubeDLDownloadStatus(Status):
|
||||
def __init__(self, obj, uid):
|
||||
def __init__(self, obj, listener):
|
||||
self.obj = obj
|
||||
self.uid = uid
|
||||
self.uid = listener.uid
|
||||
self.message = listener.message
|
||||
|
||||
def gid(self):
|
||||
return self.obj.gid
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ from bot.helper.telegram_helper.filters import CustomFilters
|
|||
from bot.helper.telegram_helper.message_utils import *
|
||||
|
||||
from time import sleep
|
||||
from bot.helper.ext_utils.bot_utils import getDownloadByGid
|
||||
from ..helper.ext_utils.bot_utils import MirrorStatus
|
||||
from bot.helper.ext_utils.bot_utils import getDownloadByGid, MirrorStatus
|
||||
|
||||
|
||||
@run_async
|
||||
|
|
@ -23,7 +22,7 @@ def cancel_mirror(bot, update):
|
|||
return
|
||||
with download_dict_lock:
|
||||
keys = list(download_dict.keys())
|
||||
mirror_message = dl.__listener.message
|
||||
mirror_message = dl.message
|
||||
elif update.message.reply_to_message:
|
||||
mirror_message = update.message.reply_to_message
|
||||
with download_dict_lock:
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class MirrorListener(listeners.MirrorListeners):
|
|||
drive = gdriveTools.GoogleDriveHelper(up_name, self)
|
||||
if size == 0:
|
||||
size = fs_utils.get_path_size(m_path)
|
||||
upload_status = UploadStatus(drive, size, self.uid)
|
||||
upload_status = UploadStatus(drive, size, self)
|
||||
with download_dict_lock:
|
||||
download_dict[self.uid] = upload_status
|
||||
update_all_messages()
|
||||
|
|
|
|||
Loading…
Reference in New Issue