Fix anonymous messages

This commit is contained in:
Andrea Cavalli 2024-07-01 11:48:38 +02:00
parent acd543ae49
commit 15f16b03ea

View File

@ -5,6 +5,7 @@ import com.github.pemistahl.lingua.api.LanguageDetector;
import com.github.pemistahl.lingua.api.LanguageDetectorBuilder;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
@ -99,11 +100,10 @@ public class LanguageBlockBot extends AbilityBot {
private CompletableFuture<Boolean> isMessageDeletable(Message msg) {
var chatId = msg.getChatId();
CompletableFuture<Boolean> canDeleteBecauseItsNotAdmin;
canDeleteBecauseItsNotAdmin = getChatAdmins(chatId)
CompletableFuture<Boolean> canDeleteBecauseItsNotAdmin = getChatAdmins(chatId)
.thenApply(admins -> !admins.contains(getSenderChat(msg)));
boolean canDeleteBecauseItsNormalMessage = !(msg.getIsAutomaticForward() != null && msg.getIsAutomaticForward())
&& (getSenderChat(msg) > 0) && !msg.hasViaBot();
&& (getSenderChat(msg) > 0) && !msg.hasViaBot() && !Objects.equals(msg.getChatId(), getSenderChat(msg));
return CompletableFuture
.completedFuture(canDeleteBecauseItsNormalMessage)