Fix /del command

This commit is contained in:
aNNiMON 2023-10-27 22:31:45 +03:00
parent 937103be94
commit 651ed41f2c

View File

@ -32,7 +32,7 @@ import com.pengrad.telegrambot.response.SendResponse;
public class BotHandler extends BaseBotHandler { public class BotHandler extends BaseBotHandler {
private static final int RADIX = 36; private static final int RADIX = 36;
private final Pattern delPattern = Pattern.compile("/del([^_]+)_(\\d+)"); private final Pattern delPattern = Pattern.compile("/del([^_]+)_([^-]+)");
private final Pattern comparePattern = Pattern.compile("/cmp([^-]+)_([^-]+)_(.*)"); private final Pattern comparePattern = Pattern.compile("/cmp([^-]+)_([^-]+)_(.*)");
private final ImageIndexer indexer; private final ImageIndexer indexer;
@ -48,6 +48,7 @@ public class BotHandler extends BaseBotHandler {
} }
protected void handleUpdates(List<Update> updates) { protected void handleUpdates(List<Update> updates) {
if (updates.isEmpty()) return;
final var removedPosts = processAdminCommands(updates); final var removedPosts = processAdminCommands(updates);
processUpdates(updates, removedPosts); processUpdates(updates, removedPosts);
} }
@ -115,6 +116,7 @@ public class BotHandler extends BaseBotHandler {
private void processUpdates(List<Update> updates, Set<Post> ignoredPosts) { private void processUpdates(List<Update> updates, Set<Post> ignoredPosts) {
final List<Message> channelPosts = getChannelPostsWithPhotos(updates); final List<Message> channelPosts = getChannelPostsWithPhotos(updates);
if (channelPosts.isEmpty()) return;
final var similarImagesInfos = new ArrayList<SimilarImagesInfo>(); final var similarImagesInfos = new ArrayList<SimilarImagesInfo>();
for (var post : channelPosts) { for (var post : channelPosts) {
final var originalPost = new Post(post.chat().id(), post.messageId()); final var originalPost = new Post(post.chat().id(), post.messageId());