Class Bot

Direct Known Subclasses:
BotLibre, OllamaBot

public abstract class Bot extends User
A Bot is a Client that has no session. It does have own scene, and observes all events in the scene. It also responds to something that user(s) write. Bots are configured in application.properties file, and instantiated by BotManager on server startup.
Author:
joe
  • Field Details

    • processing

      protected volatile boolean processing
  • Constructor Details

    • Bot

      public Bot()
  • Method Details

    • getParameter

      public String getParameter(String key)
      Returns a parameter from parameter map
    • selfTest

      public abstract void selfTest() throws Exception
      Self test runs on server startup. Exceptions are logged but otherwise ignored.
      Throws:
      Exception
    • getResponseAsync

      public abstract reactor.core.publisher.Mono<String> getResponseAsync(Client c, String query)
      Response generation method that subclasses need to override.
      Parameters:
      c - Client sending the query, typically User instance, may be Bot if respondToBots is true.
      query - Whatever user wrote.
      Returns:
      Mono that evaluates to the answer.
    • respondTo

      public void respondTo(Client c, String what)
      Get response to something that a client "said", and write it. If the client is a Bot instance, respond only if respondToBots is true. Also takes into account bot range, and ignores if client out of range. Calls getResponseAsync method, and then write if it returns anything. Errors are ignored, assuming getResponseAsync handles and logs them.
    • write

      public void write(String what)
      Utility method - "say" something, notify all listeners. Null and empty argument is silently ignored, as in no response from the bot.
    • processEvent

      public void processEvent(VREvent event)
      Process an event. If that's something that a user/bot wrote, calls respondTo method. Other events are ignored.
      Overrides:
      processEvent in class Client
      Parameters:
      event - Whatever has changed
    • objectsAdded

      public void objectsAdded(List<VRObject> objects)
      New objects in the scene, typically a client that has arrived. This implementation sets responding flag to true, to ensure bots don't stay silent forever.
    • objectsRemoved

      public void objectsRemoved(List<Map<String,String>> objects)
      Objects removed from the scene, typically a client that has left. This implementation does nothing, utility method for subclasses.
    • sendMessage

      public void sendMessage(Object o)
      Scene management method, called when the scene changes.
      Overrides:
      sendMessage in class Client
    • toString

      public String toString()
      Overrides:
      toString in class User
    • getGender

      public String getGender()
      Gender is advice for client, e.g. voice synthesis
    • getLang

      public String getLang()
      Bot language, e.g. in case it can speak more than one
    • getUrl

      public String getUrl()
      Configured URL of chatbot server, not published
    • getParameterMap

      public Map<String,String> getParameterMap()
      Configured bot parameters parameters, available through getParameter() method, not published
    • getAnimations

      public List<String> getAnimations()
      Names of available avatar animations. The list is loaded from content/rpm-anim directory, if loadAnimations is set. It can be configured and set for each bot separatelly. Hint for the bot itself, not published.
    • getWorldManager

      public WorldManager getWorldManager()
      Passed to the Bot on creation, as Bots may need access to the database or other WorldManager methods
    • getBotManager

      public BotManager getBotManager()
      Passed to the Bot on creation
    • isRespondToBots

      public boolean isRespondToBots()
    • isAsync

      public boolean isAsync()
    • getRange

      public Double getRange()
    • isProcessing

      public boolean isProcessing()
    • isResponding

      public boolean isResponding()
    • isShouldRespond

      public boolean isShouldRespond()
    • getQueryCleanup

      public Pattern getQueryCleanup()
    • setGender

      public void setGender(String gender)
      Gender is advice for client, e.g. voice synthesis
    • setLang

      public void setLang(String lang)
      Bot language, e.g. in case it can speak more than one
    • setUrl

      public void setUrl(String url)
      Configured URL of chatbot server, not published
    • setParameterMap

      public void setParameterMap(Map<String,String> parameterMap)
      Configured bot parameters parameters, available through getParameter() method, not published
    • setAnimations

      public void setAnimations(List<String> animations)
      Names of available avatar animations. The list is loaded from content/rpm-anim directory, if loadAnimations is set. It can be configured and set for each bot separatelly. Hint for the bot itself, not published.
    • setWorldManager

      public void setWorldManager(WorldManager worldManager)
      Passed to the Bot on creation, as Bots may need access to the database or other WorldManager methods
    • setBotManager

      public void setBotManager(BotManager botManager)
      Passed to the Bot on creation
    • setRespondToBots

      public void setRespondToBots(boolean respondToBots)
    • setAsync

      public void setAsync(boolean async)
    • setRange

      public void setRange(Double range)
    • setProcessing

      public void setProcessing(boolean processing)
    • setResponding

      public void setResponding(boolean responding)
    • setShouldRespond

      public void setShouldRespond(boolean shouldRespond)
    • setQueryCleanup

      public void setQueryCleanup(Pattern queryCleanup)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class User
    • canEqual

      protected boolean canEqual(Object other)
      Overrides:
      canEqual in class User
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class User