From e463aa07317362b7ad4221efe9da5064fef7e834 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Tue, 19 Jul 2022 21:51:21 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=81=D1=80=D0=B0=D0=B1=D0=B0=D1=82=D1=8B=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B1=D0=BE=D1=82=D0=B0=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=83=D0=B2=D0=B5=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B2=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D0=BE=D0=B2?= =?UTF-8?q?=D1=8B=D1=85=20=D1=87=D0=B0=D1=82=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- telegram-core/pom.xml | 2 +- .../telegram/listen/EventDistributorService.java | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index a59d692..3fcc6da 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ dev.struchkov.godfather telegram-bot - 0.0.18 + 0.0.19 pom diff --git a/telegram-core/pom.xml b/telegram-core/pom.xml index af92a34..2bf536b 100644 --- a/telegram-core/pom.xml +++ b/telegram-core/pom.xml @@ -5,7 +5,7 @@ dev.struchkov.godfather telegram-bot - 0.0.18 + 0.0.19 telegram-core diff --git a/telegram-core/src/main/java/dev/struchkov/godfather/telegram/listen/EventDistributorService.java b/telegram-core/src/main/java/dev/struchkov/godfather/telegram/listen/EventDistributorService.java index 0e8f25c..18b00f0 100644 --- a/telegram-core/src/main/java/dev/struchkov/godfather/telegram/listen/EventDistributorService.java +++ b/telegram-core/src/main/java/dev/struchkov/godfather/telegram/listen/EventDistributorService.java @@ -14,6 +14,7 @@ import org.telegram.telegrambots.meta.api.objects.CallbackQuery; import org.telegram.telegrambots.meta.api.objects.ChatMemberUpdated; import org.telegram.telegrambots.meta.api.objects.Message; import org.telegram.telegrambots.meta.api.objects.Update; +import org.telegram.telegrambots.meta.api.objects.User; import java.util.List; import java.util.Map; @@ -64,7 +65,7 @@ public class EventDistributorService implements EventDistributor { private boolean isEvent(Message message) { return message.getChannelChatCreated() != null || message.getDeleteChatPhoto() != null - || message.getNewChatMembers() != null + || isNewChatMember(message.getNewChatMembers()) || message.getNewChatTitle() != null || message.getNewChatPhoto() != null || message.getVideoChatEnded() != null @@ -74,6 +75,14 @@ public class EventDistributorService implements EventDistributor { || message.getVideoChatStarted() != null; } + private boolean isNewChatMember(List newChatMembers) { + if (newChatMembers == null) { + return true; + } else { + return !newChatMembers.isEmpty(); + } + } + private Optional> getEventProvider(String type) { return Optional.ofNullable(eventProviderMap.get(type)); }