From 87ed08e5cd71fc11c97493a56bd71281215bd78e Mon Sep 17 00:00:00 2001 From: Firepup Sixfifty Date: Tue, 14 Nov 2023 23:26:02 -0600 Subject: [PATCH] Formatting --- commands.py | 7 +++++-- config.py | 9 +++++++-- handlers.py | 8 +++++--- logs.py | 4 ++-- overrides.py | 2 +- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/commands.py b/commands.py index c98719d..15846de 100644 --- a/commands.py +++ b/commands.py @@ -101,7 +101,9 @@ def quote(bot: bare.bot, chan: str, name: str, message: str) -> None: r.seed() mm = open("mastermessages.txt", "r") q = mm.readlines() - sel = conf.decode_escapes(str(r.sample(q, 1)).strip("[]'").replace("\\n", "").strip('"')) + sel = conf.decode_escapes( + str(r.sample(q, 1)).strip("[]'").replace("\\n", "").strip('"') + ) bot.msg(sel, chan) mm.close() @@ -127,7 +129,8 @@ def debug(bot: bare.bot, chan: str, name: str, message: str) -> None: "VERSION": bot.__version__, "NICKLEN": bot.nicklen, "NICK": bot.nick, - "ADMINS": str(conf.servers[bot.server]["admins"]) + " (Does not include hostname checks)", + "ADMINS": str(conf.servers[bot.server]["admins"]) + + " (Does not include hostname checks)", "CHANNELS": bot.channels, } bot.msg(f"[DEBUG] {dbg_out}", chan) diff --git a/config.py b/config.py index c081fb0..2474d6e 100644 --- a/config.py +++ b/config.py @@ -37,7 +37,7 @@ servers: dict[str, dict[str, Any]] = { "channels": {"#default": 0, "#botrebellion": 0}, "admins": [], "hosts": ["172.20.171.225", "169.254.253.107"], - } + }, } admin_hosts: list[str] = ["firepup.firepi", "47.221.227.180"] ESCAPE_SEQUENCE_RE = re.compile( @@ -67,5 +67,10 @@ def mfind(message: str, find: list, usePrefix: bool = True) -> bool: else: return any(message[: len(match)] == match for match in find) + def adminCheck(bot: bare.bot, name: str, host: Optional[str] = "nul") -> bool: - return name.lower() in servers[bot.server]["admins"] or host in admin_hosts or host in servers[bot.server]["hosts"] + return ( + name.lower() in servers[bot.server]["admins"] + or host in admin_hosts + or host in servers[bot.server]["hosts"] + ) diff --git a/handlers.py b/handlers.py index 4afc11d..46276fd 100644 --- a/handlers.py +++ b/handlers.py @@ -45,9 +45,11 @@ def PRIVMSG(bot: bare.bot, msg: str) -> tuple[Union[None, str], Union[None, str] # Format of ":[Nick]![ident]@[host|vhost] PRIVMSG [channel] :[message]” name = msg.split("!", 1)[0][1:] host = msg.split("@", 1)[1].split(" ", 1)[0] - if (name.startswith("saxjax") and bot.server == "efnet") or ( - name == "ReplIRC" and bot.server == "replirc" - ) or (name == "FirePyLink_" and bot.server == "ircnow"): + if ( + (name.startswith("saxjax") and bot.server == "efnet") + or (name == "ReplIRC" and bot.server == "replirc") + or (name == "FirePyLink_" and bot.server == "ircnow") + ): if "<" in msg and ">" in msg: Nname = msg.split("<", 1)[1].split(">", 1)[0].strip() if name == "ReplIRC": diff --git a/logs.py b/logs.py index 84ff121..5b16435 100644 --- a/logs.py +++ b/logs.py @@ -17,9 +17,9 @@ def log( if time == "now": dtime = dt.now() elif type(time) == str: - raise ValueError("Only \"now\" is an accepted string argument for time") + raise ValueError('Only "now" is an accepted string argument for time') else: - dtime = time # type: dt #type: ignore + dtime = time # type: dt #type: ignore time = dtime.strftime("%H:%M:%S") if not "\n" in message: print(f"[{level}][{origin}][{time}] {message}", file=stream) diff --git a/overrides.py b/overrides.py index faadb1e..0c71957 100644 --- a/overrides.py +++ b/overrides.py @@ -46,7 +46,7 @@ class bytes(bbytes): def safe_decode(cls) -> str: 'Calls cls.decode(cls, errors = "ignore"), if that errors, returns a blank string' try: - return cls.decode(cls.value, errors = "ignore") # type: ignore + return cls.decode(cls.value, errors="ignore") # type: ignore except TypeError: print("panik - invalid UTF-8") return "nul"