From 52e514b3a2d80e96b4fbe5b26ec893345eec486c Mon Sep 17 00:00:00 2001 From: Firepup Sixfifty Date: Tue, 14 Nov 2023 18:50:26 -0600 Subject: [PATCH] Shorter and more pythonic --- bot.py | 6 +++--- commands.py | 2 +- handlers.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bot.py b/bot.py index eca3bab..6b80937 100644 --- a/bot.py +++ b/bot.py @@ -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") diff --git a/commands.py b/commands.py index de40e6c..c69f842 100644 --- a/commands.py +++ b/commands.py @@ -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 diff --git a/handlers.py b/handlers.py index 0f3d898..80dde6d 100644 --- a/handlers.py +++ b/handlers.py @@ -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:]