From fd2b60bfe8aaaef3a81991edb93d11c7d265ebb9 Mon Sep 17 00:00:00 2001 From: Mickael Date: Mon, 26 Aug 2019 19:08:22 +0200 Subject: [PATCH] filter system message on last message --- scripts/generate_chat_info.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/generate_chat_info.py b/scripts/generate_chat_info.py index e63952e..63a7b3a 100644 --- a/scripts/generate_chat_info.py +++ b/scripts/generate_chat_info.py @@ -41,12 +41,13 @@ def main(): print("Check messages for channels {}".format(channel['name'])) messages = rocket.channels_history(channel["_id"], oldest= recent_date, count= 10000).json() - if messages["success"]: - nbMessages = len(messages["messages"]) + if messages["success"]: + messages = list(filter(lambda message: "t" not in message, messages["messages"])) + nbMessages = len(messages) messages_recent += nbMessages if (channel["name"] != "general") and (channel["name"] != "accueil"): channels_list.append((channel["name"], nbMessages)) - users.extend(map(lambda message: message["u"]["_id"], messages["messages"])) + users.extend(map(lambda message: message["u"]["_id"], messages)) else: print("Error : {}".format(messages["error"]))