Исправил срабатывание бота на уведомления в групповых чатах
This commit is contained in:
parent
bf8ba844cf
commit
35167a00d2
2
pom.xml
2
pom.xml
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -38,8 +38,10 @@ public class EventDistributorService implements EventDistributor {
|
||||
public void processing(@NotNull Update update) {
|
||||
if (update.getMessage() != null) {
|
||||
final Message message = update.getMessage();
|
||||
getEventProvider(Mail.TYPE)
|
||||
.ifPresent(eventProviders -> eventProviders.forEach(eventProvider -> eventProvider.sendEvent(MessageMailConvert.apply(message))));
|
||||
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();
|
||||
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user