Minor tweaks & add bot.warn()

This commit is contained in:
Firepup Sixfifty 2023-11-05 20:05:34 -06:00
parent b5aee62341
commit 91161a15f9
Signed by: Firepup650
GPG key ID: 7C92E2ABBBFAB9BA

11
bot.py
View file

@ -46,16 +46,16 @@ class bot:
self.nicklen = int(ircmsg.split("NICKLEN=")[1].split(" ")[0])
self.np = re.compile(npbase.replace("MAX", f"{nicklen}"))
self.log(f"NICKLEN set to {nicklen}")
if ircmsg.find("Nickname") != -1:
elif ircmsg.find("Nickname") != -1:
self.warn("Nickname in use")
self.botnick = f"{botnick}{r.randint(0,1000)}"
self.send(f"NICK {botnick}\n")
self.log(f"botnick is now {botnick}")
if ircmsg.startswith("PING "):
elif ircmsg.startswith("PING "):
self.ping(ircmsg)
if len(ircmsg.split("\x01")) == 3:
elif len(ircmsg.split("\x01")) == 3:
self.CTCPHandler(ircmsg, isRaw=True)
if ircmsg.find("Closing Link") != -1:
elif ircmsg.find("Closing Link") != -1:
self.exit("Closing Link")
else:
self.exit("Lost connection to the server")
@ -76,6 +76,9 @@ class bot:
def log(self, message: object) -> None:
log(message, self.server)
def warn(self, message: object) -> None:
log(message, self.server, "WARN")
def exit(message: object) -> NoReturn:
log(message, self.server, "EXIT")
exit(1)