Skip to content

Commit 856ad6a

Browse files
committed
Merge branch 'master' of https://github.com/Program-O/Program-O
2 parents 26a29e6 + 8ff31b8 commit 856ad6a

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

chatbot/core/aiml/parse_aiml_as_XML.php

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ function parse_aiml_as_XML($convoArr)
3434
$botsay = trim(implode_recursive(' ', $responseArray, __FILE__, __FUNCTION__, __LINE__));
3535
$botsay = str_replace(' .', '.', $botsay);
3636
$botsay = str_replace(' ', ' ', $botsay);
37+
$botsay = str_replace(' ?', '?', $botsay);
38+
$botsay = str_replace(' ,', ',', $botsay);
39+
$botsay = str_replace(' s ', 's ', $botsay);
3740
$convoArr['aiml']['parsed_template'] = $botsay;
3841
runDebug(__FILE__, __FUNCTION__, __LINE__, "Completed parsing the template. The bot will say: $botsay", 4);
3942
return $convoArr;
@@ -277,24 +280,17 @@ function parse_get_tag($convoArr, $element, $parentName, $level)
277280
$response = 'undefined';
278281
if (empty ($response))
279282
{
280-
281-
if((isset($convoArr['client_properties'][(string)$var_name])) && ($convoArr['client_properties'][(string)$var_name]!=""))
282-
{
283-
$response = $convoArr['client_properties'][(string)$var_name];
284-
} else {
285-
286-
$sql = "select `value` from `$dbn`.`client_properties` where `user_id` = $user_id and `bot_id` = $bot_id and `name` = '$var_name';";
287-
runDebug(__FILE__, __FUNCTION__, __LINE__, "Checking the DB for $var_name - sql:\n$sql", 3);
288-
$result = db_query($sql, $con);
289-
if (($result) and (mysql_num_rows($result) > 0)) {
290-
$row = mysql_fetch_assoc($result);
291-
$response = $row['value'];
292-
}
293-
else {
294-
$response = 'undefined';
295-
}
296-
mysql_free_result($result);
283+
$sql = "select `value` from `$dbn`.`client_properties` where `user_id` = $user_id and `bot_id` = $bot_id and `name` = '$var_name';";
284+
runDebug(__FILE__, __FUNCTION__, __LINE__, "Checking the DB for $var_name - sql:\n$sql", 3);
285+
$result = db_query($sql, $con);
286+
if (($result) and (mysql_num_rows($result) > 0)) {
287+
$row = mysql_fetch_assoc($result);
288+
$response = $row['value'];
289+
}
290+
else {
291+
$response = 'undefined';
297292
}
293+
mysql_free_result($result);
298294
}
299295
runDebug(__FILE__, __FUNCTION__, __LINE__, "The value for $var_name is $response.", 4);
300296
return $response;
@@ -318,8 +314,6 @@ function parse_set_tag($convoArr, $element, $parentName, $level)
318314
if ($var_name == 'name')
319315
{
320316
$user_name = $var_value;
321-
$convoArr['client_properties']['name'] = $var_value;
322-
$convoArr['conversation']['user_name'] = $var_value;
323317
$sql = "UPDATE `$dbn`.`users` set `user_name` = '$var_value' where `id` = $user_id;";
324318
$sql = mysql_real_escape_string($sql);
325319
runDebug(__FILE__, __FUNCTION__, __LINE__, "Updating user name in the DB. SQL:\n$sql", 3);

chatbot/core/user/handle_user.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,22 @@ function intisaliseUser($convoArr)
9494
}
9595

9696
$sql = "INSERT INTO `$dbn`.`users` (`id`, `user_name`, `session_id`, `bot_id`, `chatlines` ,`ip` ,`referer` ,`browser` ,`date_logged_on` ,`last_update`, `state`)
97-
VALUES ( NULL , '$unknown_user', '$convo_id', $bot_id, '0', '$sa', '$sr', '$sb', CURRENT_TIMESTAMP , '0000-00-00 00:00:00', '')";
97+
VALUES ( NULL , '$unknown_user', '$convo_id', $bot_id, '0', '$sa', '$sr', '$sb', CURRENT_TIMESTAMP , CURRENT_TIMESTAMP, '')";
9898

9999
mysql_query($sql,$con) or trigger_error('Error trying to add user. Error = ' . mysql_error());
100100
$user_id = mysql_insert_id($con);
101101
$convoArr['conversation']['user_id'] = $user_id;
102102
$convoArr['conversation']['totallines'] = 0;
103103
runDebug( __FILE__, __FUNCTION__, __LINE__, "intisaliseUser #$user_id SQL: $sql",3);
104104

105+
106+
//add the username to the client properties....
107+
$sql = "INSERT INTO `$dbn`.`client_properties` (`id`,`user_id`,`bot_id`,`name`,`value`)
108+
VALUES ( NULL , '$user_id', $bot_id, 'name', '$unknown_user')";
109+
110+
mysql_query($sql, $con) or trigger_error('Error trying to add username to client properties. Error = ' . mysql_error());
111+
112+
105113
return $convoArr;
106114
}
107115

0 commit comments

Comments
 (0)