I did stuff... I don't remember what

This commit is contained in:
Firepup Sixfifty 2024-04-06 23:45:38 -05:00
parent 949843cca0
commit ee5bee742f
Signed by: Firepup650
GPG key ID: 7C92E2ABBBFAB9BA
4 changed files with 30 additions and 19 deletions

20
bot.py
View file

@ -32,8 +32,12 @@ class bot(bare.bot):
conf.servers[server]["port"] if "port" in conf.servers[server] else 6667 conf.servers[server]["port"] if "port" in conf.servers[server] else 6667
) )
self.channels = conf.servers[server]["channels"] self.channels = conf.servers[server]["channels"]
self.adminnames = conf.servers[server]["admins"] self.adminnames = (
self.ignores = conf.servers[server]["ignores"] conf.servers[server]["admins"] if "admins" in conf.servers[server] else []
)
self.ignores = (
conf.servers[server]["ignores"] if "ignores" in conf.servers[server] else 6667
)
self.__version__ = conf.__version__ self.__version__ = conf.__version__
self.npallowed = conf.npallowed self.npallowed = conf.npallowed
self.interval = ( self.interval = (
@ -45,7 +49,9 @@ class bot(bare.bot):
self.queue: list[bbytes] = [] # pyright: ignore [reportInvalidTypeForm] self.queue: list[bbytes] = [] # pyright: ignore [reportInvalidTypeForm]
self.sock = socket(AF_INET, SOCK_STREAM) self.sock = socket(AF_INET, SOCK_STREAM)
self.current = "user" self.current = "user"
self.threads = conf.servers[server]["threads"] self.threads = (
conf.servers[server]["threads"] if "threads" in conf.servers[server] else []
)
self.lastfmLink = conf.lastfmLink self.lastfmLink = conf.lastfmLink
self.log(f"Start init for {self.server}") self.log(f"Start init for {self.server}")
@ -251,8 +257,12 @@ class bot(bare.bot):
res, chan = handlers.handles[action](self, ircmsg) res, chan = handlers.handles[action](self, ircmsg)
if res == "reload" and type(chan) == str: if res == "reload" and type(chan) == str:
reload(conf) reload(conf)
self.adminnames = conf.servers[self.server]["admins"] self.adminnames = (
self.ignores = conf.servers[self.server]["ignores"] conf.servers[self.server]["admins"] if "admins" in conf.servers[self.server] else []
)
self.ignores = (
conf.servers[self.server]["ignores"] if "ignores" in conf.servers[self.server] else []
)
self.__version__ = conf.__version__ self.__version__ = conf.__version__
self.npallowed = conf.npallowed self.npallowed = conf.npallowed
self.interval = ( self.interval = (

View file

@ -13,7 +13,7 @@ def admin(
cmd: Optional[str] = "", cmd: Optional[str] = "",
) -> bool: ) -> bool:
if ( if (
name.lower() in conf.servers[bot.server]["admins"] name.lower() in bot.adminnames
or (host or bot.tmpHost) in conf.admin_hosts or (host or bot.tmpHost) in conf.admin_hosts
or (host or bot.tmpHost) in conf.servers[bot.server]["hosts"] or (host or bot.tmpHost) in conf.servers[bot.server]["hosts"]
): ):

View file

@ -138,7 +138,7 @@ 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"]) "ADMINS": str(bot.adminnames)
+ " (Does not include hostname checks)", + " (Does not include hostname checks)",
"CHANNELS": bot.channels, "CHANNELS": bot.channels,
} }
@ -172,8 +172,14 @@ def nowplaying(bot: bare.bot, chan: str, name: str, message: str) -> None:
) )
def fmpull(bot: bare.bot, chan: str, name: str, message: str) -> None:
try:
bot.msg("Firepup is currently listening to: " + bot.lastfmLink.get_user("Firepup650").get_now_playing().__str__(), chan)
except:
bot.msg("Sorry, the music api isn't cooperating, please try again in a minute", chan)
def whoami(bot: bare.bot, chan: str, name: str, message: str) -> None: def whoami(bot: bare.bot, chan: str, name: str, message: str) -> None:
bot.msg(f"I think you are {name} {'(bridge)' if bot.current == 'bridge' else ''}", chan) bot.msg(f"I think you are {name}{' (bridge)' if bot.current == 'bridge' else '@{bot.tmpHost}'}", chan)
data: dict[str, dict[str, Any]] = { data: dict[str, dict[str, Any]] = {
@ -197,6 +203,7 @@ data: dict[str, dict[str, Any]] = {
"whoami": {"prefix": True, "aliases": []}, "whoami": {"prefix": True, "aliases": []},
"fpmp": {"prefix": True, "aliases": []}, "fpmp": {"prefix": True, "aliases": []},
"version": {"prefix": True, "aliases": ["ver","v"]}, "version": {"prefix": True, "aliases": ["ver","v"]},
"np": {"prefix": True, "aliases": []},
} }
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]] = {
@ -221,4 +228,5 @@ call: dict[str, Callable[[bare.bot, str, str, str], None]] = {
"whoami": whoami, "whoami": whoami,
"fpmp": fpmp, "fpmp": fpmp,
"version": version, "version": version,
"np": fmpull,
} }

View file

@ -6,31 +6,26 @@ from typing import Optional, Any
import bare, pylast import bare, pylast
load_dotenv() load_dotenv()
__version__ = "v3.0.0" __version__ = "v3.0.2-dev"
npbase: str = "\[\x0303last\.fm\x03\] [A-Za-z0-9_[\]{}\\|\-^]{1,$MAX} (is listening|last listened) to: \x02.+ - .*\x02( \([0-9]+ plays\)( \[.*\])?)?" # pyright: ignore [reportInvalidStringEscapeSequence] npbase: str = "\[\x0303last\.fm\x03\] [A-Za-z0-9_[\]{}\\|\-^]{1,$MAX} (is listening|last listened) to: \x02.+ - .*\x02( \([0-9]+ plays\)( \[.*\])?)?" # pyright: ignore [reportInvalidStringEscapeSequence]
su = "^(su|sudo|(su .*|sudo .*))$" su = "^(su|sudo|(su .*|sudo .*))$"
servers: dict[str, dict[str, Any]] = { servers: dict[str, dict[str, Any]] = {
"ircnow": { "ircnow": {
"address": "0::1", "address": "127.0.0.1",
"port": 6601, "port": 6601,
"interval": 200, "interval": 200,
"pass": env["ircnow_pass"], "pass": env["ircnow_pass"],
"channels": {"#random": 0, "#dice": 0, "#offtopic": 0, "#main/replirc": 0}, "channels": {"#random": 0, "#dice": 0, "#offtopic": 0, "#main/replirc": 0},
"ignores": ["#main/replirc"], "ignores": ["#main/replirc"],
"admins": [],
"hosts": ["9pfs.repl.co"], "hosts": ["9pfs.repl.co"],
"threads": [],
}, },
"efnet": { "efnet": {
"address": "irc.mzima.net", "address": "irc.mzima.net",
"channels": {"#random": 0, "#dice": 0}, "channels": {"#random": 0, "#dice": 0},
"ignores": [],
"admins": [],
"hosts": ["154.sub-174-251-241.myvzw.com"], "hosts": ["154.sub-174-251-241.myvzw.com"],
"threads": [],
}, },
"replirc": { "replirc": {
"address": "0::1", "address": "127.0.0.1",
"pass": env["replirc_pass"], "pass": env["replirc_pass"],
"channels": {"#random": 0, "#dice": 0, "#main": 0, "#bots": 0, "#firebot": 0, "#sshchat": 0, "#firemc": 0, "#fp-radio": 0}, "channels": {"#random": 0, "#dice": 0, "#main": 0, "#bots": 0, "#firebot": 0, "#sshchat": 0, "#firemc": 0, "#fp-radio": 0},
"ignores": ["#fp-radio"], "ignores": ["#fp-radio"],
@ -39,13 +34,11 @@ servers: dict[str, dict[str, Any]] = {
"threads": ["radio"], "threads": ["radio"],
}, },
"backupbox": { "backupbox": {
"address": "0::1", "address": "127.0.0.1",
"port": 6607, "port": 6607,
"channels": {"#default": 0, "#botrebellion": 0, "#main/replirc": 0}, "channels": {"#default": 0, "#botrebellion": 0, "#main/replirc": 0},
"ignores": ["#main/replirc"], "ignores": ["#main/replirc"],
"admins": [],
"hosts": ["172.20.171.225", "169.254.253.107", "2600-6c5a-637f-1a85-0000-0000-0000-6667.inf6.spectrum.com"], "hosts": ["172.20.171.225", "169.254.253.107", "2600-6c5a-637f-1a85-0000-0000-0000-6667.inf6.spectrum.com"],
"threads": [],
}, },
} }
admin_hosts: list[str] = ["firepup.firepi", "47.221.227.180"] admin_hosts: list[str] = ["firepup.firepi", "47.221.227.180"]