Compare commits

..

No commits in common. "67cbb64a319de82e6c69c5aee47900dbbafdf4a4" and "47e377a68dbc171f63c4f6735d1c46b63c0ac82f" have entirely different histories.

5 changed files with 18 additions and 59 deletions

View file

@ -45,7 +45,6 @@ class bot:
dnsblMode: str
statuses: dict[str, dict[str, str]]
ops: dict[str, bool]
dns: dict[str, dict[str, Union[str, list[str]]]]
def __init__(self, server: str): ...

1
bot.py
View file

@ -85,7 +85,6 @@ class bot(bare.bot):
if "dnsblMode" in conf.servers[server]
else "none"
)
self.dns = {}
self.lastfmLink = conf.lastfmLink
with open("mastermessages.txt") as f:
TMFeed = []

View file

@ -290,42 +290,13 @@ def check(bot: bare.bot, chan: str, name: str, message: str) -> None:
msg = message.split(" ", 1)[1]
nick = msg.split("!")[0]
host = msg.split("@", 1)[1]
cache = host in bot.dns
dnsbl, raws = conf.dnsblHandler(bot, nick, host, chan)
bot.msg(
f"Blacklist check: {'(Cached) ' if cache else ''}{dnsbl if dnsbl else 'Safe.'} ({raws})",
chan,
)
except IndexError:
try:
host = message.split(" ", 1)[1]
cache = host in bot.dns
dnsbl, raws = conf.dnsblHandler(
bot, "thisusernameshouldbetoolongtoeveractuallybeinuse", host, chan
)
bot.msg(
f"Blacklist check: {'(Cached) ' if cache else ''}{dnsbl if dnsbl else 'Safe.'} ({raws})",
chan,
)
except Exception as E:
bot.msg("Blacklist Lookup Failed. Error recorded to bot logs.", chan)
bot.log(str(E), "FATAL")
bot.msg(f"Blacklist check: {dnsbl if dnsbl else 'Safe.'} ({raws})", chan)
except Exception as E:
bot.msg("Blacklist lookup failed. Error recorded to bot logs.", chan)
bot.log(str(E), "FATAL")
def slap(bot: bare.bot, chan: str, name: str, message: str) -> None:
msg = message.split(" ")
if len(msg) > 1:
msg = " ".join(msg[1:]).strip()
if msg == bot.nick or not msg:
msg = name
else:
msg = name
bot.msg(f"\x01ACTION slaps {msg} around a bit with {r.choice(['a firewall', 'a fireball', 'a large trout', 'a computer', 'an rpi4', 'an rpi5', 'firepi', name])}\x01", chan)
data: dict[str, dict[str, Any]] = {
"!botlist": {"prefix": False, "aliases": []},
"bugs bugs bugs": {"prefix": False, "aliases": []},
@ -366,7 +337,6 @@ data: dict[str, dict[str, Any]] = {
"setStatus": {"prefix": True, "aliases": ["sS"], "check": checks.admin},
"getStatus": {"prefix": True, "aliases": ["gS"]},
"check": {"prefix": True, "aliases": [], "check": checks.admin},
"slap": {"prefix": True, "aliases": ["s"]}
}
regexes: list[str] = [conf.npbase, conf.su]
call: dict[str, Callable[[bare.bot, str, str, str], None]] = {
@ -398,5 +368,4 @@ call: dict[str, Callable[[bare.bot, str, str, str], None]] = {
"setStatus": setStatus,
"getStatus": getStatus,
"check": check,
"slap": slap,
}

View file

@ -32,7 +32,7 @@ ipbl = DNSBLIpChecker(providers=providers)
hsbl = DNSBLDomainChecker(providers=providers)
load_dotenv()
__version__ = "v3.0.20"
__version__ = "v3.0.17"
npbase: str = (
"\[\x0303last\.fm\x03\] [A-Za-z0-9_[\]{}\\|\-^]{1,$MAX} (is listening|last listened) to: \x02.+ - .*\x02( \([0-9]+ plays\)( \[.*\])?)?" # pyright: ignore [reportInvalidStringEscapeSequence]
)
@ -198,12 +198,7 @@ def dnsblHandler(
dnsblStatus = "Not enabled"
dnsblResps = {}
if bot.dnsblMode != "none":
dnsblStatus, dnsblResps = (
dnsbl(hostname)
if not hostname in bot.dns
else (bot.dns[hostname]["status"], bot.dns[hostname]["resps"])
)
bot.dns[hostname] = {"status": dnsblStatus, "resps": dnsblResps}
dnsblStatus, dnsblResps = dnsbl(hostname)
if dnsblStatus:
match bot.dnsblMode:
case "kickban":

View file

@ -213,25 +213,22 @@ def JOIN(bot: bare.bot, msg: str) -> tuple[None, None]:
def MODE(bot: bare.bot, msg: str) -> tuple[None, None]:
chan = msg.split("#", 1)[1].split(" ", 1)[0]
add = True if msg.split("#", 1)[1].split(" ", 2)[1][0] == "+" else False
modes = msg.split("#", 1)[1].split(" ", 2)[1][1:]
users = ""
try:
chan = msg.split("#", 1)[1].split(" ", 1)[0]
add = True if msg.split("#", 1)[1].split(" ", 2)[1][0] == "+" else False
modes = msg.split("#", 1)[1].split(" ", 2)[1][1:]
users = ""
try:
users = msg.split("#", 1)[1].split(" ", 2)[2].split()
except IndexError:
...
if len(modes) != len(users):
bot.log("Refusing to handle modes that do not have corresponding users.")
return None, None
for i in range(len(modes)):
if users[i] == bot.nick:
if modes[i] == "o":
bot.ops[chan] = add
bot.log(f"{'Got' if add else 'Lost'} ops in {chan}")
except IndexError: # *our* modes are changing, not a channel
bot.log("Not handling changing of my modes")
users = msg.split("#", 1)[1].split(" ", 2)[2].split()
except IndexError:
...
if len(modes) != len(users):
bot.log("Refusing to handle modes that do not have corresponding users.")
return None, None
for i in range(len(modes)):
if users[i] == bot.nick:
if modes[i] == "o":
bot.ops[chan] = add
bot.log(f"{'Got' if add else 'Lost'} ops in {chan}")
return None, None