-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelpBot.java
41 lines (33 loc) · 1.15 KB
/
HelpBot.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* Made with all the love in the world
* by scireum in Remshalden, Germany
*
* Copyright by scireum GmbH
* http://www.scireum.de - info@scireum.de
*/
package bots;
import server.ChatMessage;
import sirius.kernel.commons.Strings;
import sirius.kernel.di.std.Register;
import java.util.function.Consumer;
/**
* Handles :help messages and responds with a short message.
* <p>
* This acts as a sample for a very basic chat bot.
*/
@Register
public class HelpBot implements ChatBot {
private static final String HANDLED_MESSAGE = ":help ";
@Override
public boolean shouldHandleMessage(ChatMessage message) {
return HANDLED_MESSAGE.equals(message.getText());
}
@Override
public void handleMessage(ChatMessage message,
Consumer<ChatMessage> responsesToUser,
Consumer<ChatMessage> responsesToEveryBody) {
responsesToUser.accept(new ChatMessage(Strings.apply("Hello %s, I'm pleased to help you!", message.getSender()),
getClass().getSimpleName()));
// Have fun here - tell everyone that someone needs help
}
}