From 02f565e522f9c87ddc9b7aa6dbddb4a76ecc3776 Mon Sep 17 00:00:00 2001 From: Firepup Sixfifty Date: Tue, 30 Apr 2024 19:09:50 -0500 Subject: [PATCH 1/2] Bug fix --- timers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/timers.py b/timers.py index fdb9462..9e20014 100644 --- a/timers.py +++ b/timers.py @@ -17,7 +17,7 @@ def is_dead(thr: Thread) -> bool: def threadWrapper(data: dict) -> NoReturn: if not data["noWrap"]: while 1: - if ignoreErrors: + if data["ignoreErrors"]: try: data["func"](*data["args"]) except Exception: @@ -118,5 +118,5 @@ def mcDown(instance: bare.bot) -> None: data: dict[str, dict[str, Any]] = { "radio": {"noWrap": True, "func": radio, "args": []}, - "mc-down": {"noWrap": False, "func": mcDown, "args": [], "interval": 60} + "mc-down": {"noWrap": False, "func": mcDown, "args": [], "interval": 60, "ignoreErrors": True} } From 0f869f1430ddf49a26fff0b5451e6c14ee892d35 Mon Sep 17 00:00:00 2001 From: Firepup Sixfifty Date: Tue, 30 Apr 2024 19:42:30 -0500 Subject: [PATCH 2/2] Formatting --- bot.py | 2 +- config.py | 2 +- timers.py | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bot.py b/bot.py index 9c8f6f0..62bb7c8 100644 --- a/bot.py +++ b/bot.py @@ -270,7 +270,7 @@ class bot(bare.bot): tdict = {} for thread in self.threads: tdict[thread] = timers.data[thread] - if thread in ["radio"]: + if tdict[thread]["passInstance"]: tdict[thread]["args"] = [self] tMgr = Thread(target=timers.threadManager, args=(tdict,)) tMgr.daemon = True diff --git a/config.py b/config.py index 5394dba..63ad37a 100644 --- a/config.py +++ b/config.py @@ -6,7 +6,7 @@ from typing import Optional, Any import bare, pylast load_dotenv() -__version__ = "v3.0.6" +__version__ = "v3.0.7-dev" npbase: str = ( "\[\x0303last\.fm\x03\] [A-Za-z0-9_[\]{}\\|\-^]{1,$MAX} (is listening|last listened) to: \x02.+ - .*\x02( \([0-9]+ plays\)( \[.*\])?)?" # pyright: ignore [reportInvalidStringEscapeSequence] ) diff --git a/timers.py b/timers.py index 9e20014..c155b85 100644 --- a/timers.py +++ b/timers.py @@ -112,11 +112,18 @@ def radio(instance: bare.bot) -> NoReturn: instance.log("Thread while loop broken", "FATAL") exit(1) + def mcDown(instance: bare.bot) -> None: instance.sendraw("TOPIC #firemc :FireMC Relay channel (offline)") data: dict[str, dict[str, Any]] = { - "radio": {"noWrap": True, "func": radio, "args": []}, - "mc-down": {"noWrap": False, "func": mcDown, "args": [], "interval": 60, "ignoreErrors": True} + "radio": {"noWrap": True, "func": radio, "passInstance": True}, + "mc-down": { + "noWrap": False, + "func": mcDown, + "passInstance": True, + "interval": 60, + "ignoreErrors": True, + }, }