From 98447c6ac0ad549486bc45150cae6b39fbbb9adf Mon Sep 17 00:00:00 2001 From: Duda Nogueira Date: Wed, 14 Sep 2022 10:14:04 -0300 Subject: [PATCH] [BASE] - New option, ignore_token_force_close_message --- rocket_connect/plugins/base.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/rocket_connect/plugins/base.py b/rocket_connect/plugins/base.py index 9a39170..e8f7235 100644 --- a/rocket_connect/plugins/base.py +++ b/rocket_connect/plugins/base.py @@ -737,11 +737,14 @@ def ingoing(self): self.handle_livechat_session_queued() if self.message.get("type") == "Message": message, created = self.register_message() + ignore_close_message = self.message_object.room.token in self.config.get( + "ignore_token_force_close_message", "" + ).split(",") if not message.delivered: # prepare message to be sent to client for message in self.message.get("messages", []): agent_name = self.get_agent_name(message) - # closing message + # closing message, if not requested do ignore if message.get("closingMessage"): if self.connector.config.get( "force_close_message", @@ -749,7 +752,7 @@ def ingoing(self): message["msg"] = self.connector.config[ "force_close_message" ] - if message.get("msg"): + if message.get("msg") and not ignore_close_message: if self.connector.config.get( "add_agent_name_at_close_message" ): @@ -757,7 +760,8 @@ def ingoing(self): else: self.outgo_text_message(message) self.close_room() - # closing message without message + # closing message without message, or mark + # ignored as delivered else: self.message_object.delivered = True self.message_object.save() @@ -939,6 +943,11 @@ def save(self): help_text="Force this message on close", required=False, ) + ignore_token_force_close_message = forms.CharField( + help_text="ignore those visitors when sending closing message." + + 'This can avoid "bot loop". Tokens separated with comma', + required=False, + ) outcome_attachment_description_as_new_message = forms.BooleanField( required=False, help_text="This might be necessary for the bot to react accordingly",