Skip to content

Commit 564ccf5

Browse files
authored
added getText
Useful if you store language dependet text in aiml files. This method gets the text for a given text-tag and does nothing else.
1 parent 58e30e5 commit 564ccf5

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/main/java/org/myrobotlab/service/ProgramAB.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,37 @@ public Response getResponse(String userName, String botName, String text, boolea
294294
return response;
295295
}
296296

297+
/**
298+
* Similar to get Response, but text only and no publishing. Useful if you store language dependet text in aiml files.
299+
* This method gets the text for a given text-tag and does nothing else.
300+
* @param inText language/bot independent text tag
301+
* @return language/bot dependent text
302+
*/
303+
public String getText(String inText) {
304+
305+
String currentUserName = getCurrentUserName();
306+
String currentBotName = getCurrentBotName();
307+
308+
Session session = getSession(currentUserName, currentBotName);
309+
310+
// if a session with this user and bot does not exist
311+
// attempt to create it
312+
if (session == null) {
313+
session = startSession(currentUserName, currentBotName);
314+
if (session == null) {
315+
error("username or bot name not valid %s %s", currentUserName, currentBotName);
316+
return null;
317+
}
318+
}
319+
320+
// Get the actual bots aiml based response for this session
321+
log.info("getResponse({})", inText);
322+
Response response = session.getResponse(inText);
323+
324+
return response.msg;
325+
}
326+
327+
297328
private Bot getBot(String botName) {
298329
return bots.get(botName).getBot();
299330
}

0 commit comments

Comments
 (0)