From 971d4841ef0740abccc489a7ace7d9a512383356 Mon Sep 17 00:00:00 2001 From: devin Date: Mon, 27 Apr 2020 19:39:12 +0900 Subject: [PATCH] Gather conversation methods first to prevent these from using as event methods --- .../me/ramswaroop/jbot/core/common/BaseBot.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/jbot/src/main/java/me/ramswaroop/jbot/core/common/BaseBot.java b/jbot/src/main/java/me/ramswaroop/jbot/core/common/BaseBot.java index 56a96579..2ef83779 100644 --- a/jbot/src/main/java/me/ramswaroop/jbot/core/common/BaseBot.java +++ b/jbot/src/main/java/me/ramswaroop/jbot/core/common/BaseBot.java @@ -42,17 +42,26 @@ public abstract class BaseBot { */ public BaseBot() { Method[] methods = this.getClass().getMethods(); + + // Gather conversation methods first to prevent these from using as event methods for (Method method : methods) { if (method.isAnnotationPresent(Controller.class)) { Controller controller = method.getAnnotation(Controller.class); - EventType[] eventTypes = controller.events(); - String pattern = controller.pattern(); - int patternFlags = controller.patternFlags(); String next = controller.next(); if (!StringUtils.isEmpty(next)) { conversationMethodNames.add(next); } + } + } + + for (Method method : methods) { + if (method.isAnnotationPresent(Controller.class)) { + Controller controller = method.getAnnotation(Controller.class); + EventType[] eventTypes = controller.events(); + String pattern = controller.pattern(); + int patternFlags = controller.patternFlags(); + String next = controller.next(); MethodWrapper methodWrapper = new MethodWrapper(); methodWrapper.setMethod(method);