better command parsing

This commit is contained in:
dsc 2022-07-20 05:24:05 +02:00
parent 12c2d3ff9f
commit 44015f2475

18
main.py
View file

@ -162,14 +162,22 @@ async def message_received(nick, target, message, **kwargs):
async def handle_msg(nick, msg, target, now: float):
global TASK_AUTHORS, TASK_QUEUE
if not msg.startswith("!dall "):
def _err(target, err):
return bot.send("PRIVMSG", target=target, message=err)
if "!dall" not in msg:
return
msg = msg[6:].strip()
spl = msg.split(' ')
if "!dall" not in spl[:2]:
return
msg = msg[msg.find("!dall"):]
msg = msg[5:].strip()
if len(msg) <= 8:
err = f"{nick}: longer query required."
bot.send("PRIVMSG", target=target, message=err)
return
return _err(target, f"longer query required.")
TASK_AUTHORS.setdefault(nick, 0)
if TASK_AUTHORS[nick] >= 3: