Minor tweaks & add bot.warn()
This commit is contained in:
parent
b5aee62341
commit
91161a15f9
1 changed files with 7 additions and 4 deletions
11
bot.py
11
bot.py
|
@ -46,16 +46,16 @@ class bot:
|
||||||
self.nicklen = int(ircmsg.split("NICKLEN=")[1].split(" ")[0])
|
self.nicklen = int(ircmsg.split("NICKLEN=")[1].split(" ")[0])
|
||||||
self.np = re.compile(npbase.replace("MAX", f"{nicklen}"))
|
self.np = re.compile(npbase.replace("MAX", f"{nicklen}"))
|
||||||
self.log(f"NICKLEN set to {nicklen}")
|
self.log(f"NICKLEN set to {nicklen}")
|
||||||
if ircmsg.find("Nickname") != -1:
|
elif ircmsg.find("Nickname") != -1:
|
||||||
self.warn("Nickname in use")
|
self.warn("Nickname in use")
|
||||||
self.botnick = f"{botnick}{r.randint(0,1000)}"
|
self.botnick = f"{botnick}{r.randint(0,1000)}"
|
||||||
self.send(f"NICK {botnick}\n")
|
self.send(f"NICK {botnick}\n")
|
||||||
self.log(f"botnick is now {botnick}")
|
self.log(f"botnick is now {botnick}")
|
||||||
if ircmsg.startswith("PING "):
|
elif ircmsg.startswith("PING "):
|
||||||
self.ping(ircmsg)
|
self.ping(ircmsg)
|
||||||
if len(ircmsg.split("\x01")) == 3:
|
elif len(ircmsg.split("\x01")) == 3:
|
||||||
self.CTCPHandler(ircmsg, isRaw=True)
|
self.CTCPHandler(ircmsg, isRaw=True)
|
||||||
if ircmsg.find("Closing Link") != -1:
|
elif ircmsg.find("Closing Link") != -1:
|
||||||
self.exit("Closing Link")
|
self.exit("Closing Link")
|
||||||
else:
|
else:
|
||||||
self.exit("Lost connection to the server")
|
self.exit("Lost connection to the server")
|
||||||
|
@ -76,6 +76,9 @@ class bot:
|
||||||
def log(self, message: object) -> None:
|
def log(self, message: object) -> None:
|
||||||
log(message, self.server)
|
log(message, self.server)
|
||||||
|
|
||||||
|
def warn(self, message: object) -> None:
|
||||||
|
log(message, self.server, "WARN")
|
||||||
|
|
||||||
def exit(message: object) -> NoReturn:
|
def exit(message: object) -> NoReturn:
|
||||||
log(message, self.server, "EXIT")
|
log(message, self.server, "EXIT")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
Loading…
Reference in a new issue