From 677b401fc63d60d53cf700d2cbcc684938f6a97b Mon Sep 17 00:00:00 2001 From: Abbas Abou Daya Date: Tue, 8 May 2018 03:39:21 +0300 Subject: [PATCH] Check if the message is a group or super group message for GROUP_ADMIN, #390 --- .../java/org/telegram/abilitybots/api/bot/AbilityBot.java | 2 +- .../java/org/telegram/abilitybots/api/bot/AbilityBotTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/AbilityBot.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/AbilityBot.java index bbabe4c3..c2024f46 100644 --- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/AbilityBot.java +++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/AbilityBot.java @@ -637,7 +637,7 @@ public abstract class AbilityBot extends TelegramLongPollingBot { Privacy privacy; int id = user.id(); - privacy = isCreator(id) ? CREATOR : isAdmin(id) ? ADMIN : isGroupAdmin(update, id)? GROUP_ADMIN : PUBLIC; + privacy = isCreator(id) ? CREATOR : isAdmin(id) ? ADMIN : (isGroupUpdate(update) || isSuperGroupUpdate(update)) && isGroupAdmin(update, id)? GROUP_ADMIN : PUBLIC; boolean isOk = privacy.compareTo(trio.b().privacy()) >= 0; diff --git a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotTest.java b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotTest.java index ff335720..29b26e01 100644 --- a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotTest.java +++ b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotTest.java @@ -362,7 +362,7 @@ public class AbilityBotTest { } @Test - public void canValidateGroupAdminPrivacy() throws TelegramApiException { + public void canValidateGroupAdminPrivacy() { Update update = mock(Update.class); Message message = mock(Message.class); org.telegram.telegrambots.api.objects.User user = mock(User.class); @@ -383,7 +383,7 @@ public class AbilityBotTest { } @Test - public void canRestrictNormalUsersFromGroupAdminAbilities() throws TelegramApiException { + public void canRestrictNormalUsersFromGroupAdminAbilities() { Update update = mock(Update.class); Message message = mock(Message.class); org.telegram.telegrambots.api.objects.User user = mock(User.class);