Formatting

This commit is contained in:
Firepup Sixfifty 2023-11-14 23:26:02 -06:00
parent fbd2188a37
commit 87ed08e5cd
Signed by: Firepup650
GPG key ID: 7C92E2ABBBFAB9BA
5 changed files with 20 additions and 10 deletions

View file

@ -101,7 +101,9 @@ def quote(bot: bare.bot, chan: str, name: str, message: str) -> None:
r.seed() r.seed()
mm = open("mastermessages.txt", "r") mm = open("mastermessages.txt", "r")
q = mm.readlines() 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) bot.msg(sel, chan)
mm.close() mm.close()
@ -127,7 +129,8 @@ def debug(bot: bare.bot, chan: str, name: str, message: str) -> None:
"VERSION": bot.__version__, "VERSION": bot.__version__,
"NICKLEN": bot.nicklen, "NICKLEN": bot.nicklen,
"NICK": bot.nick, "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, "CHANNELS": bot.channels,
} }
bot.msg(f"[DEBUG] {dbg_out}", chan) bot.msg(f"[DEBUG] {dbg_out}", chan)

View file

@ -37,7 +37,7 @@ servers: dict[str, dict[str, Any]] = {
"channels": {"#default": 0, "#botrebellion": 0}, "channels": {"#default": 0, "#botrebellion": 0},
"admins": [], "admins": [],
"hosts": ["172.20.171.225", "169.254.253.107"], "hosts": ["172.20.171.225", "169.254.253.107"],
} },
} }
admin_hosts: list[str] = ["firepup.firepi", "47.221.227.180"] admin_hosts: list[str] = ["firepup.firepi", "47.221.227.180"]
ESCAPE_SEQUENCE_RE = re.compile( ESCAPE_SEQUENCE_RE = re.compile(
@ -67,5 +67,10 @@ def mfind(message: str, find: list, usePrefix: bool = True) -> bool:
else: else:
return any(message[: len(match)] == match for match in find) return any(message[: len(match)] == match for match in find)
def adminCheck(bot: bare.bot, name: str, host: Optional[str] = "nul") -> bool: 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"]
)

View file

@ -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]” # Format of ":[Nick]![ident]@[host|vhost] PRIVMSG [channel] :[message]”
name = msg.split("!", 1)[0][1:] name = msg.split("!", 1)[0][1:]
host = msg.split("@", 1)[1].split(" ", 1)[0] host = msg.split("@", 1)[1].split(" ", 1)[0]
if (name.startswith("saxjax") and bot.server == "efnet") or ( if (
name == "ReplIRC" and bot.server == "replirc" (name.startswith("saxjax") and bot.server == "efnet")
) or (name == "FirePyLink_" and bot.server == "ircnow"): or (name == "ReplIRC" and bot.server == "replirc")
or (name == "FirePyLink_" and bot.server == "ircnow")
):
if "<" in msg and ">" in msg: if "<" in msg and ">" in msg:
Nname = msg.split("<", 1)[1].split(">", 1)[0].strip() Nname = msg.split("<", 1)[1].split(">", 1)[0].strip()
if name == "ReplIRC": if name == "ReplIRC":

View file

@ -17,9 +17,9 @@ def log(
if time == "now": if time == "now":
dtime = dt.now() dtime = dt.now()
elif type(time) == str: 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: else:
dtime = time # type: dt #type: ignore dtime = time # type: dt #type: ignore
time = dtime.strftime("%H:%M:%S") time = dtime.strftime("%H:%M:%S")
if not "\n" in message: if not "\n" in message:
print(f"[{level}][{origin}][{time}] {message}", file=stream) print(f"[{level}][{origin}][{time}] {message}", file=stream)

View file

@ -46,7 +46,7 @@ class bytes(bbytes):
def safe_decode(cls) -> str: def safe_decode(cls) -> str:
'Calls cls.decode(cls, errors = "ignore"), if that errors, returns a blank string' 'Calls cls.decode(cls, errors = "ignore"), if that errors, returns a blank string'
try: try:
return cls.decode(cls.value, errors = "ignore") # type: ignore return cls.decode(cls.value, errors="ignore") # type: ignore
except TypeError: except TypeError:
print("panik - invalid UTF-8") print("panik - invalid UTF-8")
return "nul" return "nul"