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

This commit is contained in:
Struchkov Mark 2022-07-19 20:53:59 +03:00
parent bf8ba844cf
commit 35167a00d2
3 changed files with 19 additions and 4 deletions

View File

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

View File

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

View File

@ -38,8 +38,10 @@ public class EventDistributorService implements EventDistributor {
public void processing(@NotNull Update update) { public void processing(@NotNull Update update) {
if (update.getMessage() != null) { if (update.getMessage() != null) {
final Message message = update.getMessage(); final Message message = update.getMessage();
getEventProvider(Mail.TYPE) if (!isEvent(message)) {
.ifPresent(eventProviders -> eventProviders.forEach(eventProvider -> eventProvider.sendEvent(MessageMailConvert.apply(message)))); getEventProvider(Mail.TYPE)
.ifPresent(eventProviders -> eventProviders.forEach(eventProvider -> eventProvider.sendEvent(MessageMailConvert.apply(message))));
}
} }
if (update.getCallbackQuery() != null) { if (update.getCallbackQuery() != null) {
final CallbackQuery callbackQuery = update.getCallbackQuery(); final CallbackQuery callbackQuery = update.getCallbackQuery();
@ -59,6 +61,19 @@ public class EventDistributorService implements EventDistributor {
} }
} }
private boolean isEvent(Message message) {
return message.getChannelChatCreated() != null
|| message.getDeleteChatPhoto() != null
|| message.getNewChatMembers() != null
|| message.getNewChatTitle() != null
|| message.getNewChatPhoto() != null
|| message.getVideoChatEnded() != null
|| message.getVideoChatParticipantsInvited() != null
|| message.getVideoChatScheduled() != null
|| message.getVideoNote() != null
|| message.getVideoChatStarted() != null;
}
private Optional<List<EventProvider>> getEventProvider(String type) { private Optional<List<EventProvider>> getEventProvider(String type) {
return Optional.ofNullable(eventProviderMap.get(type)); return Optional.ofNullable(eventProviderMap.get(type));
} }