Compare commits
No commits in common. "67cbb64a319de82e6c69c5aee47900dbbafdf4a4" and "47e377a68dbc171f63c4f6735d1c46b63c0ac82f" have entirely different histories.
67cbb64a31
...
47e377a68d
5 changed files with 18 additions and 59 deletions
1
bare.py
1
bare.py
|
@ -45,7 +45,6 @@ class bot:
|
||||||
dnsblMode: str
|
dnsblMode: str
|
||||||
statuses: dict[str, dict[str, str]]
|
statuses: dict[str, dict[str, str]]
|
||||||
ops: dict[str, bool]
|
ops: dict[str, bool]
|
||||||
dns: dict[str, dict[str, Union[str, list[str]]]]
|
|
||||||
|
|
||||||
def __init__(self, server: str): ...
|
def __init__(self, server: str): ...
|
||||||
|
|
||||||
|
|
1
bot.py
1
bot.py
|
@ -85,7 +85,6 @@ class bot(bare.bot):
|
||||||
if "dnsblMode" in conf.servers[server]
|
if "dnsblMode" in conf.servers[server]
|
||||||
else "none"
|
else "none"
|
||||||
)
|
)
|
||||||
self.dns = {}
|
|
||||||
self.lastfmLink = conf.lastfmLink
|
self.lastfmLink = conf.lastfmLink
|
||||||
with open("mastermessages.txt") as f:
|
with open("mastermessages.txt") as f:
|
||||||
TMFeed = []
|
TMFeed = []
|
||||||
|
|
33
commands.py
33
commands.py
|
@ -290,42 +290,13 @@ def check(bot: bare.bot, chan: str, name: str, message: str) -> None:
|
||||||
msg = message.split(" ", 1)[1]
|
msg = message.split(" ", 1)[1]
|
||||||
nick = msg.split("!")[0]
|
nick = msg.split("!")[0]
|
||||||
host = msg.split("@", 1)[1]
|
host = msg.split("@", 1)[1]
|
||||||
cache = host in bot.dns
|
|
||||||
dnsbl, raws = conf.dnsblHandler(bot, nick, host, chan)
|
dnsbl, raws = conf.dnsblHandler(bot, nick, host, chan)
|
||||||
bot.msg(
|
bot.msg(f"Blacklist check: {dnsbl if dnsbl else 'Safe.'} ({raws})", chan)
|
||||||
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")
|
|
||||||
except Exception as E:
|
except Exception as E:
|
||||||
bot.msg("Blacklist lookup failed. Error recorded to bot logs.", chan)
|
bot.msg("Blacklist lookup failed. Error recorded to bot logs.", chan)
|
||||||
bot.log(str(E), "FATAL")
|
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]] = {
|
data: dict[str, dict[str, Any]] = {
|
||||||
"!botlist": {"prefix": False, "aliases": []},
|
"!botlist": {"prefix": False, "aliases": []},
|
||||||
"bugs bugs bugs": {"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},
|
"setStatus": {"prefix": True, "aliases": ["sS"], "check": checks.admin},
|
||||||
"getStatus": {"prefix": True, "aliases": ["gS"]},
|
"getStatus": {"prefix": True, "aliases": ["gS"]},
|
||||||
"check": {"prefix": True, "aliases": [], "check": checks.admin},
|
"check": {"prefix": True, "aliases": [], "check": checks.admin},
|
||||||
"slap": {"prefix": True, "aliases": ["s"]}
|
|
||||||
}
|
}
|
||||||
regexes: list[str] = [conf.npbase, conf.su]
|
regexes: list[str] = [conf.npbase, conf.su]
|
||||||
call: dict[str, Callable[[bare.bot, str, str, str], None]] = {
|
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,
|
"setStatus": setStatus,
|
||||||
"getStatus": getStatus,
|
"getStatus": getStatus,
|
||||||
"check": check,
|
"check": check,
|
||||||
"slap": slap,
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ ipbl = DNSBLIpChecker(providers=providers)
|
||||||
hsbl = DNSBLDomainChecker(providers=providers)
|
hsbl = DNSBLDomainChecker(providers=providers)
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
__version__ = "v3.0.20"
|
__version__ = "v3.0.17"
|
||||||
npbase: str = (
|
npbase: str = (
|
||||||
"\[\x0303last\.fm\x03\] [A-Za-z0-9_[\]{}\\|\-^]{1,$MAX} (is listening|last listened) to: \x02.+ - .*\x02( \([0-9]+ plays\)( \[.*\])?)?" # pyright: ignore [reportInvalidStringEscapeSequence]
|
"\[\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"
|
dnsblStatus = "Not enabled"
|
||||||
dnsblResps = {}
|
dnsblResps = {}
|
||||||
if bot.dnsblMode != "none":
|
if bot.dnsblMode != "none":
|
||||||
dnsblStatus, dnsblResps = (
|
dnsblStatus, dnsblResps = dnsbl(hostname)
|
||||||
dnsbl(hostname)
|
|
||||||
if not hostname in bot.dns
|
|
||||||
else (bot.dns[hostname]["status"], bot.dns[hostname]["resps"])
|
|
||||||
)
|
|
||||||
bot.dns[hostname] = {"status": dnsblStatus, "resps": dnsblResps}
|
|
||||||
if dnsblStatus:
|
if dnsblStatus:
|
||||||
match bot.dnsblMode:
|
match bot.dnsblMode:
|
||||||
case "kickban":
|
case "kickban":
|
||||||
|
|
33
handlers.py
33
handlers.py
|
@ -213,25 +213,22 @@ def JOIN(bot: bare.bot, msg: str) -> tuple[None, None]:
|
||||||
|
|
||||||
|
|
||||||
def MODE(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:
|
try:
|
||||||
chan = msg.split("#", 1)[1].split(" ", 1)[0]
|
users = msg.split("#", 1)[1].split(" ", 2)[2].split()
|
||||||
add = True if msg.split("#", 1)[1].split(" ", 2)[1][0] == "+" else False
|
except IndexError:
|
||||||
modes = msg.split("#", 1)[1].split(" ", 2)[1][1:]
|
...
|
||||||
users = ""
|
if len(modes) != len(users):
|
||||||
try:
|
bot.log("Refusing to handle modes that do not have corresponding users.")
|
||||||
users = msg.split("#", 1)[1].split(" ", 2)[2].split()
|
return None, None
|
||||||
except IndexError:
|
for i in range(len(modes)):
|
||||||
...
|
if users[i] == bot.nick:
|
||||||
if len(modes) != len(users):
|
if modes[i] == "o":
|
||||||
bot.log("Refusing to handle modes that do not have corresponding users.")
|
bot.ops[chan] = add
|
||||||
return None, None
|
bot.log(f"{'Got' if add else 'Lost'} ops in {chan}")
|
||||||
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")
|
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue