Исправил срабатывание бота на уведомления в групповых чатах

This commit is contained in:
Struchkov Mark 2022-07-19 21:51:21 +03:00
parent 35167a00d2
commit e463aa0731
3 changed files with 12 additions and 3 deletions

View File

@ -5,7 +5,7 @@
<groupId>dev.struchkov.godfather</groupId>
<artifactId>telegram-bot</artifactId>
<version>0.0.18</version>
<version>0.0.19</version>
<packaging>pom</packaging>
<modules>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>dev.struchkov.godfather</groupId>
<artifactId>telegram-bot</artifactId>
<version>0.0.18</version>
<version>0.0.19</version>
</parent>
<artifactId>telegram-core</artifactId>

View File

@ -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<User> newChatMembers) {
if (newChatMembers == null) {
return true;
} else {
return !newChatMembers.isEmpty();
}
}
private Optional<List<EventProvider>> getEventProvider(String type) {
return Optional.ofNullable(eventProviderMap.get(type));
}