Shorter and more pythonic

This commit is contained in:
Firepup Sixfifty 2023-11-14 18:50:26 -06:00
parent 0930f8b561
commit 52e514b3a2
Signed by: Firepup650
GPG key ID: 7C92E2ABBBFAB9BA
3 changed files with 5 additions and 5 deletions

6
bot.py
View file

@ -58,7 +58,7 @@ class bot(bare.bot):
except (IndexError, ValueError):
self.log("Err - No code")
print(bytes(ircmsg).lazy_decode())
if ircmsg.find("NICKLEN=") != -1:
if "NICKLEN" in ircmsg:
self.nicklen = int(ircmsg.split("NICKLEN=")[1].split(" ")[0])
self.log(f"NICKLEN set to {self.nicklen}")
if code == 433:
@ -69,14 +69,14 @@ class bot(bare.bot):
if code in [376, 422]:
self.log(f"Success by code: {code}")
break
if ircmsg.find(f"MODE {self.nick}") >= 0 or ircmsg.find(f"PRIVMSG {self.nick}") >= 0:
if "MODE" in ircmsg or "PRIVMSG" in ircmsg:
self.log(f"Success by MSG/MODE")
break
if ircmsg.startswith("PING "):
self.ping(ircmsg)
if len(ircmsg.split("\x01")) == 3:
handlers.CTCP(self, ircmsg)
if ircmsg.find("Closing Link") != -1:
if "Closing link" in ircmsg:
self.exit("Closing Link")
else:
self.exit("Lost connection to the server")

View file

@ -60,7 +60,7 @@ def help(bot: bare.bot, chan: str, name: str, message: str) -> None:
if (name.startswith("saxjax") and bot.server == "efnet") or (
name == "ReplIRC" and bot.server == "replirc"
):
if message.find("<") != -1 and message.find(">") != -1:
if "<" in message and "<" in message:
helpErr = True
elif name.endswith("dsc"):
helpErr = True

View file

@ -47,7 +47,7 @@ def PRIVMSG(bot: bare.bot, msg: str) -> tuple[Union[None, str], Union[None, str]
if (name.startswith("saxjax") and bot.server == "efnet") or (
name == "ReplIRC" and bot.server == "replirc"
) or (name == "FirePyLink_" and bot.server == "ircnow"):
if msg.find("<") != -1 and msg.find(">") != -1:
if "<" in msg and ">" in msg:
Nname = msg.split("<", 1)[1].split(">", 1)[0].strip()
if name == "ReplIRC":
name = Nname[4:]