From f8a71f20a2d095bad2524fd0128c692e42371cda Mon Sep 17 00:00:00 2001 From: Rilliat Date: Fri, 13 Jun 2025 23:39:42 +0300 Subject: [PATCH 1/3] remove hikari`s ubguard as redundant (err 521) --- heroku/dispatcher.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/heroku/dispatcher.py b/heroku/dispatcher.py index d18a3cf..25470b1 100644 --- a/heroku/dispatcher.py +++ b/heroku/dispatcher.py @@ -145,7 +145,6 @@ class CommandDispatcher: self.raw_handlers = [] self._external_bl: typing.List[int] = [] - asyncio.ensure_future(self._external_bl_reload_loop()) async def _handle_ratelimit(self, message: Message, func: callable) -> bool: if await self.security.check(message, security.OWNER): @@ -713,15 +712,3 @@ class CommandDispatcher: await func(message) except Exception as e: await exception_handler(e, message, *args) - - async def _external_bl_reload_loop(self): - while True: - with contextlib.suppress(Exception): - self._external_bl = ( - await utils.run_sync( - requests.get, - "https://ubguard.dan.tatar/blacklist.json", - ) - ).json()["blacklist"] - - await asyncio.sleep(60) From 399270e59a52a7a03f14e2cac2936baa1a99a109 Mon Sep 17 00:00:00 2001 From: Rilliat Date: Fri, 13 Jun 2025 23:41:50 +0300 Subject: [PATCH 2/3] =?UTF-8?q?=D0=A2=D0=A0=D0=95=D0=9F=D0=95=D0=A9=D0=98?= =?UTF-8?q?=20=D0=9F=D0=95=D0=A0=D0=A0=D0=98=20=D0=A5=D0=A3=D0=95=D0=A1?= =?UTF-8?q?=D0=9E=D0=A1=20=D0=AF=20=D0=98=D0=97=D0=9E=D0=91=D0=A0=D0=95?= =?UTF-8?q?=D0=9B=20=D0=A5=D0=95=D0=A0=D0=9E=D0=9A=D0=A3=20=D0=9D=D0=90=20?= =?UTF-8?q?=D0=92=D0=98=D0=9D=D0=94=D0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- heroku/loader.py | 2 +- heroku/main.py | 31 ++++++++++++++++++++++--------- heroku/modules/heroku_info.py | 3 ++- heroku/utils.py | 3 +++ 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/heroku/loader.py b/heroku/loader.py index 72d6ae7..c705643 100644 --- a/heroku/loader.py +++ b/heroku/loader.py @@ -620,7 +620,7 @@ class Modules: spec = importlib.machinery.ModuleSpec( module_name, - StringLoader(Path(mod).read_text(), user_friendly_origin), + StringLoader(Path(mod).read_text(encoding='utf-8'), user_friendly_origin), origin=user_friendly_origin, ) diff --git a/heroku/main.py b/heroku/main.py index 830b007..e6a925d 100644 --- a/heroku/main.py +++ b/heroku/main.py @@ -98,11 +98,14 @@ IS_AEZA = "aeza" in socket.gethostname() IS_USERLAND = "userland" in os.environ.get("USER", "") IS_JAMHOST = "JAMHOST" in os.environ IS_WSL = False +IS_WINDOWS = False with contextlib.suppress(Exception): from platform import uname if "microsoft-standard" in uname().release: IS_WSL = True + elif uname().system == "Windows": + IS_WINDOWS = True # fmt: off LATIN_MOCK = [ @@ -827,10 +830,10 @@ class Heroku: logo = ( " _ \n" - " /\ /\ ___ _ __ ___ | | __ _ _ \n" - " / /_/ // _ \| '__|/ _ \ | |/ /| | | |\n" + r" /\ /\ ___ _ __ ___ | | __ _ _ ""\n" + r" / /_/ // _ \| '__|/ _ \ | |/ /| | | |""\n" "/ __ /| __/| | | (_) || < | |_| |\n" - "\/ /_/ \___||_| \___/ |_|\_\ \__,_|\n\n" + r"\/ /_/ \___||_| \___/ |_|\_\ \__,_|""\n\n" f"• Build: {build[:7]}\n" f"• Version: {'.'.join(list(map(str, list(__version__))))}\n" f"• {upd}\n" @@ -990,14 +993,24 @@ class Heroku: def main(self): """Main entrypoint""" - self.loop.add_signal_handler( - signal.SIGINT, - lambda: asyncio.create_task(self._shutdown_handler()) - ) + if sys.platform != "win32": + try: + self.loop.add_signal_handler( + signal.SIGINT, + lambda: asyncio.create_task(self._shutdown_handler()) + ) + except NotImplementedError: + logging.warning("Signal handlers not supported on this platform.") + else: + logging.info("Running on Windows — skipping signal handler.") + try: self.loop.run_until_complete(self._main()) - except: - pass + except KeyboardInterrupt: + logging.info("KeyboardInterrupt received.") + self.loop.run_until_complete(self._shutdown_handler()) + except Exception as e: + logging.exception("Unexpected exception in main loop: %s", e) finally: logging.info("Bye!") self.loop.run_until_complete(self._shutdown_handler()) diff --git a/heroku/modules/heroku_info.py b/heroku/modules/heroku_info.py index f1de66f..09000e3 100644 --- a/heroku/modules/heroku_info.py +++ b/heroku/modules/heroku_info.py @@ -137,7 +137,8 @@ class HerokuInfoMod(loader.Module): ("🌼", "❤️"), ("🎡", "🎡"), ("🐧", "🐧"), - ("🧃", "🧃") + ("🧃", "🧃"), + ("💻", "💻"), ]: platform = platform.replace(emoji, icon) return ( diff --git a/heroku/utils.py b/heroku/utils.py index 154fdbd..0a2f385 100644 --- a/heroku/utils.py +++ b/heroku/utils.py @@ -921,6 +921,9 @@ def get_named_platform() -> str: if main.IS_WSL: return "🍀 WSL" + if main.IS_WINDOWS: + return "💻 Windows" + if main.IS_JAMHOST: return "🧃 JamHost" From 095adc6a771be41e05d2a4d363e52525a0044948 Mon Sep 17 00:00:00 2001 From: Rilliat Date: Fri, 13 Jun 2025 23:48:30 +0300 Subject: [PATCH 3/3] Revert "remove hikari`s ubguard as redundant (err 521)" This reverts commit f8a71f20a2d095bad2524fd0128c692e42371cda. --- heroku/dispatcher.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/heroku/dispatcher.py b/heroku/dispatcher.py index 25470b1..d18a3cf 100644 --- a/heroku/dispatcher.py +++ b/heroku/dispatcher.py @@ -145,6 +145,7 @@ class CommandDispatcher: self.raw_handlers = [] self._external_bl: typing.List[int] = [] + asyncio.ensure_future(self._external_bl_reload_loop()) async def _handle_ratelimit(self, message: Message, func: callable) -> bool: if await self.security.check(message, security.OWNER): @@ -712,3 +713,15 @@ class CommandDispatcher: await func(message) except Exception as e: await exception_handler(e, message, *args) + + async def _external_bl_reload_loop(self): + while True: + with contextlib.suppress(Exception): + self._external_bl = ( + await utils.run_sync( + requests.get, + "https://ubguard.dan.tatar/blacklist.json", + ) + ).json()["blacklist"] + + await asyncio.sleep(60)