forked from Firepup650/FireBot
Add ignored channels, and reload more when reloading
This commit is contained in:
parent
3c9f11cc52
commit
cc82ae7893
4 changed files with 23 additions and 5 deletions
1
bare.py
1
bare.py
|
@ -33,6 +33,7 @@ class bot:
|
|||
npallowed: list[str]
|
||||
current: str
|
||||
tmpHost: str
|
||||
ignores: list[str]
|
||||
|
||||
def __init__(self, server: str):
|
||||
...
|
||||
|
|
17
bot.py
17
bot.py
|
@ -30,17 +30,18 @@ class bot(bare.bot):
|
|||
conf.servers[server]["port"] if "port" in conf.servers[server] else 6667
|
||||
)
|
||||
self.channels = conf.servers[server]["channels"]
|
||||
self.adminnames = conf.servers[server]["admins"]
|
||||
self.ignores = conf.servers[server]["ignores"]
|
||||
self.__version__ = conf.__version__
|
||||
self.npallowed = conf.npallowed
|
||||
self.interval = (
|
||||
conf.servers[server]["interval"]
|
||||
if "interval" in conf.servers[server]
|
||||
else 50
|
||||
)
|
||||
self.__version__ = conf.__version__
|
||||
self.nick = "FireBot"
|
||||
self.adminnames = conf.servers[server]["admins"]
|
||||
self.queue: list[bbytes] = [] # pyright: ignore [reportInvalidTypeForm]
|
||||
self.sock = socket(AF_INET, SOCK_STREAM)
|
||||
self.npallowed = ["FireBitBot"]
|
||||
self.current = "user"
|
||||
self.log(f"Start init for {self.server}")
|
||||
|
||||
|
@ -236,7 +237,15 @@ class bot(bare.bot):
|
|||
res, chan = handlers.handles[action](self, ircmsg)
|
||||
if res == "reload" and type(chan) == str:
|
||||
reload(conf)
|
||||
self.adminnames = conf.servers[self.server]["admins"]
|
||||
self.ignores = conf.servers[self.server]["ignores"]
|
||||
self.__version__ = conf.__version__
|
||||
self.npallowed = conf.npallowed
|
||||
self.interval = (
|
||||
conf.servers[self.server]["interval"]
|
||||
if "interval" in conf.servers[self.server]
|
||||
else 50
|
||||
)
|
||||
reload(cmds)
|
||||
reload(handlers)
|
||||
self.msg("Reloaded successfully", chan)
|
||||
|
@ -247,4 +256,6 @@ class bot(bare.bot):
|
|||
self.exit("I got killed :'(")
|
||||
elif ircmsg.startswith("ERROR :Ping "):
|
||||
self.exit("Ping timeout")
|
||||
else:
|
||||
self.log("Unrecognized server request!", "WARN")
|
||||
self.exit("While loop broken")
|
||||
|
|
|
@ -6,7 +6,7 @@ from typing import Optional, Any
|
|||
import bare
|
||||
|
||||
load_dotenv()
|
||||
__version__ = "v2.0.12"
|
||||
__version__ = "v2.0.13"
|
||||
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 .*))$"
|
||||
servers: dict[str, dict[str, Any]] = {
|
||||
|
@ -16,12 +16,14 @@ servers: dict[str, dict[str, Any]] = {
|
|||
"interval": 200,
|
||||
"pass": env["ircnow_pass"],
|
||||
"channels": {"#random": 0, "#dice": 0, "#offtopic": 0, "#main/replirc": 0},
|
||||
"ignores": ["#main/replirc"],
|
||||
"admins": [],
|
||||
"hosts": ["9pfs.repl.co"],
|
||||
},
|
||||
"efnet": {
|
||||
"address": "irc.mzima.net",
|
||||
"channels": {"#random": 0, "#dice": 0},
|
||||
"ignores": [],
|
||||
"admins": [],
|
||||
"hosts": ["154.sub-174-251-241.myvzw.com"],
|
||||
},
|
||||
|
@ -29,12 +31,14 @@ servers: dict[str, dict[str, Any]] = {
|
|||
"address": "localhost",
|
||||
"pass": env["replirc_pass"],
|
||||
"channels": {"#random": 0, "#dice": 0, "#main": 0, "#bots": 0, "#firebot": 0, "#sshchat": 0},
|
||||
"ignores": [],
|
||||
"admins": ["h-tl"],
|
||||
"hosts": ["owner.firepi"],
|
||||
},
|
||||
"backupbox": {
|
||||
"address": "172.23.11.5",
|
||||
"channels": {"#default": 0, "#botrebellion": 0, "#main/replirc": 0},
|
||||
"ignores": ["#main/replirc"],
|
||||
"admins": [],
|
||||
"hosts": ["172.20.171.225", "169.254.253.107"],
|
||||
},
|
||||
|
@ -52,7 +56,7 @@ ESCAPE_SEQUENCE_RE = re.compile(
|
|||
re.UNICODE | re.VERBOSE,
|
||||
)
|
||||
prefix = "."
|
||||
|
||||
npallowed: list[str] = ["FireBitBot"]
|
||||
|
||||
def decode_escapes(s: str) -> str:
|
||||
def decode_match(match):
|
||||
|
|
|
@ -75,6 +75,8 @@ def PRIVMSG(bot: bare.bot, msg: str) -> Union[tuple[None, None], tuple[str, str]
|
|||
message = msg.split("PRIVMSG", 1)[1].split(":", 1)[1].strip()
|
||||
chan = msg.split("PRIVMSG", 1)[1].split(":", 1)[0].strip()
|
||||
message = conf.sub(message, bot, chan, name)
|
||||
if chan in bot.ignores:
|
||||
return None, None
|
||||
bot.log(
|
||||
f'Got "{bytes(message).lazy_decode()}" from "{name}" in "{chan}" ({bot.current})',
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue