I’m not a very strong Java developer (though I wrote RiveScript-Java), and I don’t know much about Eclipse, but the source of RSBot.java might help?
I’d just make sure the com/rivescript/ package is on my classpath somewhere, and use its API from my own Java code in a way similar to RSBot.java, like
import com.rivescript.RiveScript;
public class MyRobot {
public static void main (String[] args) {
// Create a new RiveScript interpreter.
RiveScript rs = new RiveScript();
// Load and sort replies
rs.loadDirectory("./Aiden");
rs.sortReplies();
// Get a reply from the bot.
String reply = rs.reply("user", "hello bot");
System.out.println("Bot: " + reply);
}
}
For a real bot what you’d probably do is not deal with RiveScript in your main class but put it in another class file (like Brain.java or something), and have the RiveScript object be a class attribute so it can be loaded into memory once when your bot starts up and then be called on to get a reply. Might look like,
import com.rivescript.RiveScript;
public class Brain {
private RiveScript rs; // class attribute to hold the RiveScript instance
/**
* Initialize the RiveScript brain by loading its replies from `path`.
*/
public void setUp(String path) {
this.rs = new RiveScript();
this.rs.loadDirectory(path);
this.rs.sortReplies();
}
/**
* Fetch a reply from the bot.
*/
public String reply(String user, String message) {
// Get a reply from the bot.
String reply = rs.reply(user, message);
return reply;
}
}
Your main code could then import your Brain.java file and call its `setUp()` method with the path to replies on disk (”./Aiden” or w/e), and its `reply()` method to get a reply. You could extend that with other useful methods, such as one to expose the underlying RiveScript object in case your program needs it for any special cases (getting/setting a user variable for example).
(Disclaimer: I haven’t tested this code so it might not compile as-is, but it should be enough to get you started).