Skip to content

Commit e6b0f9c

Browse files
committed
Gather conversation methods first to prevent these from using as event
methods
1 parent 349b3d0 commit e6b0f9c

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

  • jbot/src/main/java/me/ramswaroop/jbot/core/common

jbot/src/main/java/me/ramswaroop/jbot/core/common/BaseBot.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,26 @@ public abstract class BaseBot {
4242
*/
4343
public BaseBot() {
4444
Method[] methods = this.getClass().getMethods();
45+
46+
// Gather conversation methods first to prevent these from using as event methods
4547
for (Method method : methods) {
4648
if (method.isAnnotationPresent(Controller.class)) {
4749
Controller controller = method.getAnnotation(Controller.class);
48-
EventType[] eventTypes = controller.events();
49-
String pattern = controller.pattern();
50-
int patternFlags = controller.patternFlags();
5150
String next = controller.next();
5251

5352
if (!StringUtils.isEmpty(next)) {
5453
conversationMethodNames.add(next);
5554
}
55+
}
56+
}
57+
58+
for (Method method : methods) {
59+
if (method.isAnnotationPresent(Controller.class)) {
60+
Controller controller = method.getAnnotation(Controller.class);
61+
EventType[] eventTypes = controller.events();
62+
String pattern = controller.pattern();
63+
int patternFlags = controller.patternFlags();
64+
String next = controller.next();
5665

5766
MethodWrapper methodWrapper = new MethodWrapper();
5867
methodWrapper.setMethod(method);
@@ -75,6 +84,8 @@ public BaseBot() {
7584
methodNameMap.put(method.getName(), methodWrapper);
7685
}
7786
}
87+
88+
7889
}
7990

8091
protected void startConversation(String id, String methodName) {

0 commit comments

Comments
 (0)