Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
5hojib committed Jul 12, 2024
1 parent 542ba1d commit b915310
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 16 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ruff_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Ruff
on: [ push, pull_request ]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
File renamed without changes.
6 changes: 4 additions & 2 deletions bot/helper/ext_utils/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ def handleIndex(index, dic):
while True:
if abs(index) < len(dic):
break
if index < 0: index = len(dic) - abs(index)
elif index > 0: index = index - len(dic)
if index < 0:
index = len(dic) - abs(index)
elif index > 0:
index = index - len(dic)
return index


Expand Down
2 changes: 0 additions & 2 deletions bot/helper/ext_utils/files_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ async def split_file(path, size, file_, dirpath, split_size, listener, start_tim
dirpath = f"{dirpath}/splited_files"
if not await aiopath.exists(dirpath):
await mkdir(dirpath)
user_id = listener.message.from_user.id
user_dict = user_data.get(user_id, {})
leech_split_size = MAX_SPLIT_SIZE
parts = -(-size // leech_split_size)
if (await get_document_type(path))[0]:
Expand Down
9 changes: 3 additions & 6 deletions bot/helper/listeners/tasks_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from asyncio import create_subprocess_exec, sleep, Event
from pyrogram.enums import ChatType

from bot import Interval, aria2, download_dict, download_dict_lock, LOGGER, MAX_SPLIT_SIZE, config_dict, status_reply_dict_lock, user_data, non_queued_up, non_queued_dl, queued_up, queued_dl, queue_dict_lock, GLOBAL_EXTENSION_FILTER
from bot import Interval, aria2, download_dict, download_dict_lock, LOGGER, MAX_SPLIT_SIZE, config_dict, status_reply_dict_lock, non_queued_up, non_queued_dl, queued_up, queued_dl, queue_dict_lock, GLOBAL_EXTENSION_FILTER
from bot.helper.ext_utils.bot_utils import extra_btns, sync_to_async, get_readable_file_size, get_readable_time
from bot.helper.ext_utils.files_utils import get_base_name, get_path_size, clean_download, split_file, process_file, clean_target, is_first_archive_split, is_archive, is_archive_split, join_files
from bot.helper.ext_utils.exceptions import NotSupportedExtractionArchive
Expand Down Expand Up @@ -74,7 +74,6 @@ async def onDownloadStart(self):
msg += f'<b>• Task by:</b> {self.tag}\n'
msg += f'<b>• User ID: </b><code>{self.message.from_user.id}</code>'
self.linkslogmsg = await sendCustomMsg(config_dict['LEECH_LOG_ID'], msg)
user_dict = user_data.get(self.message.from_user.id, {})
self.botpmmsg = await sendCustomMsg(self.message.from_user.id, '<b>Task started</b>')

async def onDownloadComplete(self):
Expand Down Expand Up @@ -127,8 +126,7 @@ async def onDownloadComplete(self):
if self.uid in non_queued_dl:
non_queued_dl.remove(self.uid)
await start_from_queued()
user_dict = user_data.get(self.message.from_user.id, {})


if self.join:
if await aiopath.isdir(dl_path):
await join_files(dl_path)
Expand Down Expand Up @@ -335,7 +333,6 @@ async def onDownloadComplete(self):
async def onUploadComplete(self, link, size, files, folders, mime_type, name, rclonePath=''):
user_id = self.message.from_user.id
name, _ = await process_file(name, user_id, isMirror=not self.isLeech)
user_dict = user_data.get(user_id, {})
msg = f'{escape(name)}\n\n'
msg += f'<blockquote><b>• Size: </b>{get_readable_file_size(size)}\n'
msg += f'<b>• Elapsed: </b>{get_readable_time(time() - self.message.date.timestamp())}\n'
Expand Down Expand Up @@ -412,7 +409,7 @@ async def onUploadComplete(self, link, size, files, folders, mime_type, name, rc
msg += f'<b>• By: </b>{self.tag}</blockquote>\n\n'

if config_dict['MIRROR_LOG_ID']:
log_msg = list((await sendMultiMessage(config_dict['MIRROR_LOG_ID'], msg, button)).values())[0]
await sendMultiMessage(config_dict['MIRROR_LOG_ID'], msg, button)
if self.linkslogmsg:
await deleteMessage(self.linkslogmsg)
await sendMessage(self.botpmmsg, msg, button, 'Random')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,6 @@ def __writeContents(html_text, folderPath=''):
def doods(url):
if "/e/" in url:
url = url.replace("/e/", "/d/")
parsed_url = urlparse(url)
api_url = f"https://api.pake.tk/dood?url={url}"
response = requests.get(api_url)
if response.status_code != 200:
Expand All @@ -1032,8 +1031,6 @@ def hubdrive(url):
try:
rs = Session()
resp = rs.get(url)
title = findall(r'>(.*?)<\/h4>', resp.text)[0]
size = findall(r'>(.*?)<\/td>', resp.text)[1]
p_url = urlparse(url)
js_query = rs.post(f"{p_url.scheme}://{p_url.hostname}/ajax.php?ajax=direct-download", data={'id': str(url.split('/')[-1])}, headers={'x-requested-with': 'XMLHttpRequest'}).json()
if str(js_query['code']) == '200':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async def add_download(self, message, path, filename, session):
await delete_links(self.__listener.message)
return
if limit_exceeded := await limit_checker(size, self.__listener):
await listener.onDownloadError(limit_exceeded)
await self.__listener.onDownloadError(limit_exceeded)
await delete_links(self.__listener.message)
return
added_to_queue, event = await is_queued(self.__listener.uid)
Expand Down
2 changes: 1 addition & 1 deletion bot/modules/bot_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ async def get_buttons(key=None, edit_type=None, edit_mode=None, mess=None):
if edit_mode and key not in bool_vars:
msg += 'Send a valid value for the above Var. <b>Timeout:</b> 60 sec'
if key in bool_vars:
if not (value := config_dict.get(key)):
if not config_dict.get(key):
buttons.callback('Make it True', f"botset boolvar {key} on")
else:
buttons.callback('Make it False', f"botset boolvar {key} off")
Expand Down
1 change: 0 additions & 1 deletion bot/modules/users_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ async def get_user_settings(from_user, key=None, edit_type=None, edit_mode=None)
buttons.callback("RClone", f"userset {user_id} rcc")
rccmsg = "Exists" if await aiopath.exists(rclone_path) else "Not Exists"
tds_mode = "Enabled" if user_dict.get('td_mode') else "Disabled"
user_tds = len(val) if (val := user_dict.get('user_tds', False)) else 0
buttons.callback("User TDs", f"userset {user_id} user_tds")

text = f'<b>Mirror Settings for {name}</b>\n\n'
Expand Down

0 comments on commit b915310

Please sign in to comment.