forked from Firepup650/FireBot
Simplification
This commit is contained in:
parent
149946b65a
commit
bb4e8716dd
1 changed files with 12 additions and 13 deletions
25
commands.py
25
commands.py
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue