From 564ccf5f584dfdad273637d02bf27faae0be4bfd Mon Sep 17 00:00:00 2001 From: "S.Feldmann" Date: Thu, 24 Jul 2025 15:38:11 +0200 Subject: [PATCH] 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. --- .../org/myrobotlab/service/ProgramAB.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/main/java/org/myrobotlab/service/ProgramAB.java b/src/main/java/org/myrobotlab/service/ProgramAB.java index 7852274d87..af6bb95517 100644 --- a/src/main/java/org/myrobotlab/service/ProgramAB.java +++ b/src/main/java/org/myrobotlab/service/ProgramAB.java @@ -294,6 +294,37 @@ public Response getResponse(String userName, String botName, String text, boolea return response; } + /** + * Similar to get Response, but text only and no publishing. Useful if you store language dependet text in aiml files. + * This method gets the text for a given text-tag and does nothing else. + * @param inText language/bot independent text tag + * @return language/bot dependent text + */ + public String getText(String inText) { + + String currentUserName = getCurrentUserName(); + String currentBotName = getCurrentBotName(); + + Session session = getSession(currentUserName, currentBotName); + + // if a session with this user and bot does not exist + // attempt to create it + if (session == null) { + session = startSession(currentUserName, currentBotName); + if (session == null) { + error("username or bot name not valid %s %s", currentUserName, currentBotName); + return null; + } + } + + // Get the actual bots aiml based response for this session + log.info("getResponse({})", inText); + Response response = session.getResponse(inText); + + return response.msg; + } + + private Bot getBot(String botName) { return bots.get(botName).getBot(); }