Skip to content

Commit a8dc8a7

Browse files
committed
Code clenaup
Re-arranged the order of some of the final debug entries, and added a condition test for the presence of a <star> tag before performing a string replacement.
1 parent a2a6147 commit a8dc8a7

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

chatbot/conversation_start.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,20 +160,15 @@
160160
$time_start = $convoArr['time_start'];
161161
$time_end = microtime(true);
162162
$time = round(($time_end - $time_start) * 1000,4);
163-
runDebug(__FILE__, __FUNCTION__, __LINE__, "Conversation Ending. Elapsed time: $time milliseconds.", 0);
164-
runDebug(__FILE__, __FUNCTION__, __LINE__, "FINAL CONVO ARRAY",4);
165-
$final_convoArr = $convoArr;
166-
unset($final_convoArr['nounList']);
167-
runDebug(__FILE__, __FUNCTION__, __LINE__, print_r($final_convoArr,true), 4);
168163
unset($convoArr['nounList']);
164+
$final_convoArr = $convoArr;
169165
}
170166
else
171167
{
172168
runDebug(__FILE__, __FUNCTION__, __LINE__, "Conversation intialised waiting user", 2);
173169
}
174-
#if ($display == '') $display = $convoArr['send_to_user'];
175170
runDebug(__FILE__, __FUNCTION__, __LINE__, "Closing Database", 2);
176171
db_close($con);
177-
//save_file(_DEBUG_PATH_ . 'function_list.txt', print_r(get_defined_functions()['user'], true));
178172
display_conversation($convoArr);
173+
runDebug(__FILE__, __FUNCTION__, __LINE__, "Conversation Ending. Elapsed time: $time milliseconds.", 0);
179174
$convoArr = handleDebug($convoArr); // Make sure this is the last line in the file, so that all debug entries are captured.

chatbot/core/aiml/parse_aiml_as_XML.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,8 @@ function parse_html_tag($convoArr, $element, $parentName, $level)
568568
$response_string = $element->asXML();
569569
$response_string = str_replace('<text>', '', $response_string);
570570
$response_string = str_replace('</text>', '', $response_string);
571-
$star = $convoArr['star'][1];
572-
$response_string = str_replace('<star/>', $star, $response_string);
571+
$star = (isset($convoArr['star'][1])) ? $convoArr['star'][1] : '';
572+
if ($star != '') $response_string = str_replace('<star/>', $star, $response_string);
573573
return $response_string;
574574
}
575575

0 commit comments

Comments
 (0)