From d31b3d96e969255dc2c095d7452f1bee9817a3f5 Mon Sep 17 00:00:00 2001 From: Remigijus Kiminas Date: Tue, 20 Dec 2022 05:39:07 -0500 Subject: [PATCH] Random response for not replying operator --- .../fields/erlhabstractmodelautoresponder.php | 16 ++++++++-------- .../erlhabstractmodelautoresponder.php | 11 ++++++++++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lhc_web/lib/core/lhabstract/fields/erlhabstractmodelautoresponder.php b/lhc_web/lib/core/lhabstract/fields/erlhabstractmodelautoresponder.php index 1bec2e1667..92c633c5e8 100644 --- a/lhc_web/lib/core/lhabstract/fields/erlhabstractmodelautoresponder.php +++ b/lhc_web/lib/core/lhabstract/fields/erlhabstractmodelautoresponder.php @@ -403,7 +403,7 @@ 'timeout_op_reply_message_1' => array( 'type' => 'textarea', 'height' => '86px', - 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message for timeout [1]'), + 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message for timeout [1], use ||| to separate random messages.'), 'required' => false, 'hidden' => true, 'main_attr' => 'bot_configuration_array', @@ -413,7 +413,7 @@ 'timeout_op_reply_message_2' => array( 'type' => 'textarea', 'height' => '86px', - 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message for timeout [2]'), + 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message for timeout [2], use ||| to separate random messages.'), 'required' => false, 'hidden' => true, 'main_attr' => 'bot_configuration_array', @@ -423,7 +423,7 @@ 'timeout_op_reply_message_3' => array( 'type' => 'textarea', 'height' => '86px', - 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message for timeout [3]'), + 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message for timeout [3], use ||| to separate random messages.'), 'required' => false, 'hidden' => true, 'main_attr' => 'bot_configuration_array', @@ -433,7 +433,7 @@ 'timeout_op_reply_message_4' => array( 'type' => 'textarea', 'height' => '86px', - 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message for timeout [4]'), + 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message for timeout [4], use ||| to separate random messages.'), 'required' => false, 'hidden' => true, 'main_attr' => 'bot_configuration_array', @@ -443,7 +443,7 @@ 'timeout_op_reply_message_5' => array( 'type' => 'textarea', 'height' => '86px', - 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message for timeout [5]'), + 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message for timeout [5], use ||| to separate random messages.'), 'required' => false, 'hidden' => true, 'main_attr' => 'bot_configuration_array', @@ -498,7 +498,7 @@ )), 'close_message' => array( 'type' => 'textarea', - 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message to visitor on chat close'), + 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message to visitor on chat close. Use ||| to separate random messages.'), 'height' => '86px', 'required' => false, 'hidden' => true, @@ -508,7 +508,7 @@ )), 'offline_message' => array( 'type' => 'textarea', - 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message to visitor if department is offline'), + 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message to visitor if department is offline. Use ||| to separate random messages.'), 'height' => '86px', 'required' => false, 'hidden' => true, @@ -518,7 +518,7 @@ )), 'multilanguage_message' => array( 'type' => 'textarea', - 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message to visitor if operator speaks same language as visitor.'), + 'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation', 'Message to visitor if operator speaks same language as visitor. Use ||| to separate random messages.'), 'height' => '86px', 'required' => false, 'hidden' => true, diff --git a/lhc_web/lib/models/lhabstract/erlhabstractmodelautoresponder.php b/lhc_web/lib/models/lhabstract/erlhabstractmodelautoresponder.php index 50aca6ad5d..682dbe7e54 100644 --- a/lhc_web/lib/models/lhabstract/erlhabstractmodelautoresponder.php +++ b/lhc_web/lib/models/lhabstract/erlhabstractmodelautoresponder.php @@ -145,7 +145,16 @@ public function __get($var) case 'multilanguage_message': $this->{$var} = null; if (isset($this->bot_configuration_array[$var])) { - $this->{$var} = $this->bot_configuration_array[$var]; + + $msgData = explode('|||', $this->bot_configuration_array[$var]); + + if (count($msgData) > 1) { + $item = trim($msgData[mt_rand(0,count($msgData)-1)]); + } else { + $item = $this->bot_configuration_array[$var]; + } + + $this->{$var} = $item; } return $this->{$var}; break;