diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c94957c1..2f2153a8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: args: [--py36-plus] - repo: https://github.com/asottile/pyupgrade - rev: v3.19.0 + rev: v3.19.1 hooks: - id: pyupgrade args: [--py36-plus] diff --git a/Powers/database/locks_db.py b/Powers/database/locks_db.py index c4a9fc7b..fac4bdf7 100644 --- a/Powers/database/locks_db.py +++ b/Powers/database/locks_db.py @@ -92,7 +92,7 @@ def get_lock_channel(self, chat: int, locktype: str = "all"): to_return["anti_fwd"]["user"] = True elif i["locktype"] == "anti_fwd_c": to_return["anti_fwd"]["chat"] = True - elif i["anti_links"] == "anti_links": + elif i["locktype"] == "anti_links": to_return["anti_links"] = True elif i["locktype"] == "bot": to_return["bot"] = True diff --git a/Powers/plugins/dev.py b/Powers/plugins/dev.py index 536a95c2..1da043df 100644 --- a/Powers/plugins/dev.py +++ b/Powers/plugins/dev.py @@ -720,6 +720,7 @@ async def forward_type_broadcast(c: Gojo, m: Message): • /neofetch : Fetch neo. • /eval : Evaluate the given python code. • /exec : Execute the given code. +• /minfo [module name]: Give info about module • /chatlist : Return the list of chats present in database • /uptime : Return the uptime of the bot. • /leavechat : Bot will leave the provided chat. diff --git a/Powers/plugins/info.py b/Powers/plugins/info.py index 3a546491..095c87ab 100644 --- a/Powers/plugins/info.py +++ b/Powers/plugins/info.py @@ -241,12 +241,11 @@ async def info_func(c: Gojo, message: Message): return try: user, _, user_name = await extract_user(c, message) - except Exception: - await message.reply_text("Got Some errors failed to fetch user info") + except Exception as e: + await message.reply_text(f"Got Some errors failed to fetch user info\n{e}") LOGGER.error(e) - LOGGER.error(format_exc) - if not user: - await message.reply_text("Can't find user to fetch info!") + LOGGER.error(format_exc()) + return m = await message.reply_text( f"Fetching {f'@{user_name}' if user_name else 'user'} info from telegram's database..." diff --git a/Powers/plugins/locks.py b/Powers/plugins/locks.py index b993c417..97b4a085 100644 --- a/Powers/plugins/locks.py +++ b/Powers/plugins/locks.py @@ -254,6 +254,7 @@ async def convert_to_emoji(val: bool): Can send links: {vantil} Can bot send messages: {vantibot} """ + await chkmsg.edit_text(permission_view_str) except RPCError as e_f: await chkmsg.edit_text(text="Something went wrong!") await m.reply_text(e_f) diff --git a/Powers/plugins/stickers.py b/Powers/plugins/stickers.py index c08c1652..b77fc526 100644 --- a/Powers/plugins/stickers.py +++ b/Powers/plugins/stickers.py @@ -276,7 +276,7 @@ async def memify_it(c: Gojo, m: Message): kb = IKM( [ [ - IKB("Join for memes", url="https://t.me/memesofdank") + IKB("You might like", url="https://t.me/me_and_ghost") ] ] ) @@ -331,7 +331,7 @@ async def get_sticker_from_file(c: Gojo, m: Message): if repl.sticker: if repl.sticker.is_animated: upp = await repl.download() - up = tgs_to_gif(upp, True) + up = await tgs_to_gif(upp, True) await x.delete() await m.reply_animation(up, caption=Caption) elif repl.sticker.is_video: diff --git a/Powers/plugins/web_con.py b/Powers/plugins/web_con.py index 8b8ed189..b255c41a 100644 --- a/Powers/plugins/web_con.py +++ b/Powers/plugins/web_con.py @@ -304,6 +304,7 @@ async def download_instareels(c: Gojo, m: Message): content = insta.get_media() if content["code"] == 69 or content["message"] != "success": + await to_edit.delete() return await m.reply_text(content["message"]) try: diff --git a/Powers/utils/web_helpers.py b/Powers/utils/web_helpers.py index ad7fa126..194affe6 100644 --- a/Powers/utils/web_helpers.py +++ b/Powers/utils/web_helpers.py @@ -140,7 +140,7 @@ async def song_search(query, max_results=1): except Exception as e: LOGGER.error(e) LOGGER.error(format_exc()) - return yt_dict + return {0: e} nums = 1 for i in results["result"]: durr = i['duration'].split(":") @@ -169,7 +169,7 @@ async def song_search(query, max_results=1): thumb = {"thumbnail": i["thumbnails"][0]["url"]} except Exception: thumb = {"thumbnail": None} - dict_form |= thumb + dict_form.update(thumb) yt_dict[nums] = dict_form nums += 1 return yt_dict @@ -226,6 +226,9 @@ async def youtube_downloader(c: Gojo, m: Message, query: str, type_: str): ext = "mp4" # ydl = yt_dlp.YoutubeDL(opts) dicti = await song_search(query, 1) + if err := dicti.get(0, None): + await m.reply_text(err) + return if not dicti and type(dicti) != str: await m.reply_text("File with duration less than or equals to 10 minutes is allowed only") elif type(dicti) == str: diff --git a/Powers/utils/web_scrapper.py b/Powers/utils/web_scrapper.py index b5ba56d5..29ff3fa5 100644 --- a/Powers/utils/web_scrapper.py +++ b/Powers/utils/web_scrapper.py @@ -6,7 +6,6 @@ from Powers import * - # import requests # from selenium import webdriver # from selenium.webdriver.chrome.options import Options @@ -210,7 +209,8 @@ def get_videos(self) -> list: # else: # return {} - +curr_timeout = 20 +timeout = httpx.Timeout(curr_timeout) class INSTAGRAM: def __init__(self, url): @@ -220,10 +220,27 @@ def is_correct_url(self): return bool((re.compile(r"^https?://(?:www\.)?instagram\.com/")).match(self.url)) def get_media(self): + global curr_timeout try: return httpx.post( - f"https://api.qewertyy.dev/downloaders/instagram?url={self.url}" + f"https://api.qewertyy.dev/downloaders/instagram?url={self.url}", + timeout=timeout ).json() + except httpx.ReadTimeout: + try: + curr_timeout += 10 + timeout = httpx.Timeout(curr_timeout) + return httpx.post( + f"https://api.qewertyy.dev/downloaders/instagram?url={self.url}", + timeout=timeout + ).json() + except httpx.ReadTimeout: + return {"code": 69, "message": "Please retry after few seconds"} + except Exception as e: + LOGGER.error(e) + LOGGER.error(format_exc()) + return {"code": 69, "message": e} + except Exception as e: LOGGER.error(e) LOGGER.error(format_exc()) diff --git a/Procfile b/Procfile index 4a873cbe..3bc15d0c 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -worker: pip install --upgrade pip setuptools wheel && pip install -r requirements.txt && python3 -m Powers \ No newline at end of file +worker: python3 -m Powers diff --git a/requirements.txt b/requirements.txt index 4943bc9d..8c7874dc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,25 +1,26 @@ -aiofiles==23.2.1 +aiofiles==24.1.0 apscheduler==3.10.4 asyncio==3.4.3 beautifulsoup4==4.12.3 cachetools==5.2.0 captcha==0.6.0 -certifi==2024.7.4 +certifi==2024.12.14 charset-normalizer==3.4.0 dnspython==2.6.1 google==3.0.0 gpytranslate==1.5.1 -httpx +httpx==0.27.2 lyricsgenius==3.0.1 pillow == 10.3.0 +lottie==0.7.1 lxml==4.9.1 pillow == 10.3.0 prettyconf==2.2.1 pyaes==1.6.1 pymongo==4.6.3 -git+https://github.com/KurimuzonAkuma/pyrogram.git@v2.1.32 +git+https://github.com/KurimuzonAkuma/pyrogram.git@v2.1.34 pysocks==1.7.1 -python-dateutil==2.8.2 +python-dateutil==2.9.0.post0 pytube==15.0.0 pytz==2024.1 pyyaml==6.0.2 @@ -34,7 +35,7 @@ soupsieve==2.4 tgcrypto==1.2.5 tswift==0.7.0 typing-extensions -ujson==5.8.0 +ujson==5.10.0 Unidecode wikipedia==1.4.0 youtube-search-python==1.6.6