Simplification

This commit is contained in:
Firepup Sixfifty 2023-11-20 20:11:44 -06:00
parent 149946b65a
commit bb4e8716dd
Signed by: Firepup650
GPG key ID: 7C92E2ABBBFAB9BA

View file

@ -94,22 +94,21 @@ def goatOff(bot: bare.bot, chan: str, name: str, message: str) -> None:
def quote(bot: bare.bot, chan: str, name: str, message: str) -> None: def quote(bot: bare.bot, chan: str, name: str, message: str) -> None:
qfilter = ".*" qfilter = ""
query = "null" query = ""
if " " in message: if " " in message:
query = message.split(" ", 1)[1] query = message.split(" ", 1)[1]
qfilter = f".*{query}.*".replace(" ", "\s") qfilter = query.replace(" ", "\s")
r.seed() r.seed()
mm = open("mastermessages.txt", "r") with open("mastermessages.txt", "r") as mm:
quotes = mm.readlines() quotes = mm.readlines()
q = list(filter(lambda x: re.match(qfilter, x), quotes)) q = list(filter(lambda x: re.search(qfilter, x), quotes))
if q == []: if q == []:
q = [f'No results for "{query}" '] q = [f'No results for "{query}" ']
sel = conf.decode_escapes( sel = conf.decode_escapes(
str(r.sample(q, 1)).strip("[]'").replace("\\n", "").strip('"') str(r.sample(q, 1)).strip("[]'").replace("\\n", "").strip('"')
) )
bot.msg(sel, chan) bot.msg(sel, chan)
mm.close()
def join(bot: bare.bot, chan: str, name: str, message: str) -> None: def join(bot: bare.bot, chan: str, name: str, message: str) -> None: