Skip to content

Commit

Permalink
[BASE] - New option, ignore_token_force_close_message
Browse files Browse the repository at this point in the history
  • Loading branch information
dudanogueira committed Sep 14, 2022
1 parent 31ff1f9 commit 98447c6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions rocket_connect/plugins/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,27 +737,31 @@ 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",
):
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"
):
self.outgo_text_message(message, agent_name=agent_name)
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()
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 98447c6

Please sign in to comment.