Updated wiki

This commit is contained in:
Christian Blos 2020-10-08 15:33:30 +02:00
parent 5b465e79f3
commit a1034707e3
2 changed files with 16 additions and 1 deletions

View File

@ -64,4 +64,15 @@ protected boolean allowContinuousText() {
Please note that this may cause ability overlap. If multiple abilities can match the same command, the longest match will be taken. For example, Please note that this may cause ability overlap. If multiple abilities can match the same command, the longest match will be taken. For example,
if you have two abilities `do` and `do1`, the command `/do1` will trigger the `do1` ability. if you have two abilities `do` and `do1`, the command `/do1` will trigger the `do1` ability.
## Statistics ## Statistics
AbilityBot can accrue basic statistics about the usage of your abilities and replies. Simply `enableStats()` on an Ability builder or `enableStats(<name>)` on replies to activate this feature. Once activated, you may call `/stats` and the bot will print a basic list of statistics. At the moment, AbilityBot only tracks hits. In the future, this will be enhanced to track more stats. AbilityBot can accrue basic statistics about the usage of your abilities and replies. Simply `enableStats()` on an Ability builder or `enableStats(<name>)` on replies to activate this feature. Once activated, you may call `/stats` and the bot will print a basic list of statistics. At the moment, AbilityBot only tracks hits. In the future, this will be enhanced to track more stats.
## Execute code on bot registration
If you want to execute custom logic to initialize your bot, but you can't do it in the constructor,
you can override the `onRegister()` method:
```
@Override
public void onRegister() {
super.onRegister();
// Execute custom initialize logic here
}
```

View File

@ -104,6 +104,8 @@ public class ExampleBotTest {
public void setUp() { public void setUp() {
// Create your bot // Create your bot
bot = new ExampleBot(); bot = new ExampleBot();
// Call onRegister() to initialize abilities etc.
bot.onRegister();
// Create a new sender as a mock // Create a new sender as a mock
silent = mock(SilentSender.class); silent = mock(SilentSender.class);
// Set your bot silent sender to the mocked sender // Set your bot silent sender to the mocked sender
@ -156,6 +158,7 @@ public class ExampleBotTest {
// Offline instance will get deleted at JVM shutdown // Offline instance will get deleted at JVM shutdown
db = MapDBContext.offlineInstance("test"); db = MapDBContext.offlineInstance("test");
bot = new ExampleBot(db); bot = new ExampleBot(db);
bot.onRegister();
... ...
} }
@ -180,6 +183,7 @@ public class ExampleBotTest {
@Before @Before
public void setUp() { public void setUp() {
bot = new ExampleBot(db); bot = new ExampleBot(db);
bot.onRegister();
sender = mock(MessageSender.class); sender = mock(MessageSender.class);
SilentSender silent = new SilentSender(sender); SilentSender silent = new SilentSender(sender);
// Create setter in your bot // Create setter in your bot