Updated wiki
This commit is contained in:
parent
5b465e79f3
commit
a1034707e3
@ -65,3 +65,14 @@ Please note that this may cause ability overlap. If multiple abilities can match
|
||||
if you have two abilities `do` and `do1`, the command `/do1` will trigger the `do1` ability.
|
||||
## 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.
|
||||
|
||||
## 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
|
||||
}
|
||||
```
|
||||
|
@ -104,6 +104,8 @@ public class ExampleBotTest {
|
||||
public void setUp() {
|
||||
// Create your bot
|
||||
bot = new ExampleBot();
|
||||
// Call onRegister() to initialize abilities etc.
|
||||
bot.onRegister();
|
||||
// Create a new sender as a mock
|
||||
silent = mock(SilentSender.class);
|
||||
// Set your bot silent sender to the mocked sender
|
||||
@ -156,6 +158,7 @@ public class ExampleBotTest {
|
||||
// Offline instance will get deleted at JVM shutdown
|
||||
db = MapDBContext.offlineInstance("test");
|
||||
bot = new ExampleBot(db);
|
||||
bot.onRegister();
|
||||
|
||||
...
|
||||
}
|
||||
@ -180,6 +183,7 @@ public class ExampleBotTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
bot = new ExampleBot(db);
|
||||
bot.onRegister();
|
||||
sender = mock(MessageSender.class);
|
||||
SilentSender silent = new SilentSender(sender);
|
||||
// Create setter in your bot
|
||||
|
Loading…
Reference in New Issue
Block a user