Compare commits
6 commits
47e377a68d
...
67cbb64a31
Author | SHA1 | Date | |
---|---|---|---|
67cbb64a31 | |||
50473cc700 | |||
72d554340b | |||
af89d25fce | |||
433f57beb8 | |||
19ff5ee010 |
5 changed files with 59 additions and 18 deletions
1
bare.py
1
bare.py
|
@ -45,6 +45,7 @@ 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
1
bot.py
|
@ -85,6 +85,7 @@ 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 = []
|
||||
|
|
33
commands.py
33
commands.py
|
@ -290,13 +290,42 @@ 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: {dnsbl if dnsbl else 'Safe.'} ({raws})", 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")
|
||||
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": []},
|
||||
|
@ -337,6 +366,7 @@ 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]] = {
|
||||
|
@ -368,4 +398,5 @@ call: dict[str, Callable[[bare.bot, str, str, str], None]] = {
|
|||
"setStatus": setStatus,
|
||||
"getStatus": getStatus,
|
||||
"check": check,
|
||||
"slap": slap,
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ ipbl = DNSBLIpChecker(providers=providers)
|
|||
hsbl = DNSBLDomainChecker(providers=providers)
|
||||
|
||||
load_dotenv()
|
||||
__version__ = "v3.0.17"
|
||||
__version__ = "v3.0.20"
|
||||
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,7 +198,12 @@ def dnsblHandler(
|
|||
dnsblStatus = "Not enabled"
|
||||
dnsblResps = {}
|
||||
if bot.dnsblMode != "none":
|
||||
dnsblStatus, dnsblResps = dnsbl(hostname)
|
||||
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}
|
||||
if dnsblStatus:
|
||||
match bot.dnsblMode:
|
||||
case "kickban":
|
||||
|
|
|
@ -213,6 +213,7 @@ def JOIN(bot: bare.bot, msg: str) -> tuple[None, None]:
|
|||
|
||||
|
||||
def MODE(bot: bare.bot, msg: str) -> tuple[None, None]:
|
||||
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:]
|
||||
|
@ -229,6 +230,8 @@ def MODE(bot: bare.bot, msg: str) -> tuple[None, None]:
|
|||
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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue