Fix a big with chatlog length checking

Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
This commit is contained in:
Ari Archer 2022-07-17 12:55:21 +03:00
parent 7fde9f42fd
commit 0c643698b8
Signed by untrusted user who does not match committer: ari
GPG key ID: A50D5B4B599AF8A2

View file

@ -659,6 +659,9 @@ class CommandParser:
def chatlog_entry(message: str, user: str, header: Optional[str] = None) -> None:
if len(STATE["chatlog"]) > CONFIG["chatlog-limit"]:
STATE["chatlog"].clear()
STATE["chatlog"].append(
f"\n{(str(header) + ' ') if header is not None else ''}\
{user!r} @ {datetime.strftime(datetime.utcnow(), '%Y-%m-%d %H:%M:%S (%f microseconds)')} UTC: \
@ -676,9 +679,6 @@ class MessageParser:
str_msg: str = " ".join(content[1:])
user: str = content[0].strip()
if len(STATE["chatlog"]) > CONFIG["chatlog-limit"]:
STATE["chatlog"].clear()
if user and user != CONFIG["bot-name"]:
chatlog_entry(str_msg, user)