... | ... | @@ -60,18 +60,20 @@ An AIModule is basically the same as a dynamic response for a question. But inst |
|
|
To create a module the only thing you have to do is create a class and make it extend `be.maximvdw.qaplugin.api.AIModule`
|
|
|
|
|
|
```java
|
|
|
@ModuleName("ModuleName")
|
|
|
@ModuleAuthor("Maximvdw")
|
|
|
@ModuleDescription("Description about your module")
|
|
|
public class MyModule extends AIModule{
|
|
|
|
|
|
public MyModule() {
|
|
|
super("modulename","Maximvdw","Description here");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
```
|
|
|
If you are creating a module the class will automatically be initialized, if you are adding this inside a plugin you will have to initialize the class in order for it to be registered. Make sure to do a check to see if the QAPlugin is installed before doing so.
|
|
|
|
|
|
The first argument of the constructor is the **action name**, this is the name of your action and has to be the same as the action you put in your intent response.
|
|
|
The second argument is the name of the author and the third argument is a simple description of the module.
|
|
|
Every module requires a *name*, *author* and *description*. These are defined by using annotations on your AIModule class.
|
|
|
|
|
|
#### Returning a dynamic response
|
|
|
The first thing to do is to overwrite the `getResponse` method of the AIModule.
|
... | ... | @@ -81,10 +83,13 @@ The `getResponse` expects a string to be returned as the answer. It comes with a |
|
|
It is called after a question has been linked to your module.
|
|
|
|
|
|
```java
|
|
|
@ModuleName("ModuleName")
|
|
|
@ModuleAuthor("Maximvdw")
|
|
|
@ModuleDescription("Description about your module")
|
|
|
public class MyModule extends AIModule{
|
|
|
|
|
|
public MyModule() {
|
|
|
super("modulename","Maximvdw","Description here");
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
... | ... | @@ -106,11 +111,12 @@ It is useful if you have 'generic' questions that need a contexts. An example wo |
|
|
Do not use contexts for data that is always available. Only use it for information that is temporary such as when you are on a location, when are doing something specific , ... .
|
|
|
|
|
|
```java
|
|
|
@ModuleName("ModuleName")
|
|
|
@ModuleAuthor("Maximvdw")
|
|
|
@ModuleDescription("Description about your module")
|
|
|
public class MyModule extends AIModule{
|
|
|
|
|
|
public MyModule() {
|
|
|
super("modulename","Maximvdw","Description here");
|
|
|
|
|
|
Intent questName = new Intent("proquests.quest.name")
|
|
|
// ONLY, AND ONLY match this question
|
|
|
// when we found a contexts called "proquests"
|
... | ... | |