fix(admin check): check for admin if a member doesn't ha the admins privileges but have prefix

This commit is contained in:
doryan 2024-06-18 00:17:24 +04:00
parent f9abd1592e
commit c76364c8b4

View File

@ -4,7 +4,16 @@ pub fn is_admin(all_admin_members: &Vec<ChatMember>, user_id: i64) -> bool {
all_admin_members
.iter()
.any(|admin: &ChatMember| match admin {
ChatMember::Administrator(admin) => admin.user.id == user_id,
ChatMember::Administrator(admin) => {
admin.user.id == user_id
&& admin.can_change_info
&& admin.can_delete_messages
&& admin.can_promote_members
&& admin.can_manage_chat
&& admin.can_restrict_members
&& admin.can_invite_users
&& admin.can_manage_topics.unwrap()
}
ChatMember::Owner(owner) => owner.user.id == user_id,
_ => false,
})