From ffd90c9d687f80ca665b9e94bf57e4cb87cdf3ab Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Sun, 26 Mar 2023 17:43:08 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=81=D1=82=D0=B0=D1=80=D1=82=D0=B5=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/TelegramBotAutoconfiguration.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/dev/struchkov/godfather/telegram/starter/config/TelegramBotAutoconfiguration.java b/src/main/java/dev/struchkov/godfather/telegram/starter/config/TelegramBotAutoconfiguration.java index cac05f6..5eb9590 100644 --- a/src/main/java/dev/struchkov/godfather/telegram/starter/config/TelegramBotAutoconfiguration.java +++ b/src/main/java/dev/struchkov/godfather/telegram/starter/config/TelegramBotAutoconfiguration.java @@ -6,9 +6,11 @@ import dev.struchkov.godfather.simple.context.repository.PersonSettingRepository import dev.struchkov.godfather.simple.context.repository.StorylineRepository; import dev.struchkov.godfather.simple.context.repository.UnitPointerRepository; import dev.struchkov.godfather.simple.context.service.ErrorHandler; +import dev.struchkov.godfather.simple.context.service.EventDispatching; import dev.struchkov.godfather.simple.context.service.EventHandler; import dev.struchkov.godfather.simple.context.service.PersonSettingService; import dev.struchkov.godfather.simple.context.service.UnitPointerService; +import dev.struchkov.godfather.simple.core.EventDispatchingImpl; import dev.struchkov.godfather.simple.core.action.AnswerCheckAction; import dev.struchkov.godfather.simple.core.action.AnswerSaveAction; import dev.struchkov.godfather.simple.core.action.AnswerTextChatMailAction; @@ -36,6 +38,7 @@ import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -204,11 +207,17 @@ public class TelegramBotAutoconfiguration { } @Bean - @ConditionalOnBean(TelegramConnect.class) + @ConditionalOnMissingBean(EventDispatching.class) + public EventDispatching eventDispatching(List eventHandlers) { + return new EventDispatchingImpl(eventHandlers); + } + + @Bean + @ConditionalOnBean(EventDispatching.class) public EventDistributor eventDistributor( - TelegramConnect telegramConnect, List eventProviders + TelegramConnect telegramConnect, EventDispatching eventDispatching ) { - return new EventDistributorService(telegramConnect, (List) eventProviders); + return new EventDistributorService(telegramConnect, eventDispatching); } }