Skip to content
Discussion options

You must be logged in to vote

getChatAdministrators(chatId) already returns only the owner and administrators. Compare each returned member user ID with the sender:

bool senderIsAdmin = false;
for (const auto& member : bot.getApi().getChatAdministrators(message->chat->id)) {
    std::visit(
        [&](const auto& admin) {
            if (admin && admin->user && message->from && admin->user->id == message->from->id) {
                senderIsAdmin = true;
            }
        },
        member->value);
}

The bot must be allowed to obtain the administrator list. If you need particular permissions, inspect the ChatMemberAdministrator alternative; the owner is represented by ChatMemberOwner and has all administrator pri…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by reo7sp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants