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

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>
<artifactId>telegram-bot</artifactId>
<version>0.0.17</version>
<version>0.0.18</version>
<packaging>pom</packaging>
<modules>

View File

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

View File

@ -38,9 +38,11 @@ public class EventDistributorService implements EventDistributor {
public void processing(@NotNull Update update) {
if (update.getMessage() != null) {
final Message message = update.getMessage();
if (!isEvent(message)) {
getEventProvider(Mail.TYPE)
.ifPresent(eventProviders -> eventProviders.forEach(eventProvider -> eventProvider.sendEvent(MessageMailConvert.apply(message))));
}
}
if (update.getCallbackQuery() != null) {
final CallbackQuery callbackQuery = update.getCallbackQuery();
getEventProvider(Mail.TYPE)
@ -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) {
return Optional.ofNullable(eventProviderMap.get(type));
}