Exemple #1
0
def can_delete(chat: Chat, bot_id: int) -> bool:
    return chat.get_member(bot_id).can_delete_messages
Exemple #2
0
def is_user_in_chat(chat: Chat, user_id: int) -> bool:
    member = chat.get_member(user_id)
    return member.status not in ('left', 'kicked')
def user_can_delete(chat: Chat, user: User, bot_id: int) -> bool:
    return chat.get_member(bot_id).can_delete_messages and chat.get_member(
        user.id).can_delete_messages
def bot_can_restrict(chat: Chat, bot_id: int) -> bool:
    return chat.get_member(bot_id).can_restrict_members
Exemple #5
0
def user_can_promote(chat: Chat, user: User, bot_id: int) -> bool:
    return chat.get_member(user.id).can_promote_members
Exemple #6
0
def user_can_ban(chat: Chat, user: User, bot_id: int) -> bool:
    return chat.get_member(user.id).can_restrict_members
Exemple #7
0
def user_can_pin(chat: Chat, user: User, bot_id: int) -> bool:
    return chat.get_member(user.id).can_pin_messages
Exemple #8
0
def user_can_changeinfo(chat: Chat, user: User, bot_id: int) -> bool:
    return chat.get_member(user.id).can_change_info
Exemple #9
0
def user_can_voicechat(chat: Chat, user: User, bot_id: int) -> bool:
    return chat.get_member(user.id).user_can_voice_chat
Exemple #10
0
def user_can_beanonymous(chat: Chat, user: User, bot_id: int) -> bool:
    return chat.get_member(user.id).user_can_be_anonymous
Exemple #11
0
 def from_chat(self, chat: Chat):
     chat_member: ChatMember = chat.get_member(self.user_id)
     chat_member.status
Exemple #12
0
def check_permissions(chat: Chat, user: User, permission: str) -> bool:
    member: ChatMember = chat.get_member(user.id)
    if member.status == member.CREATOR:
        return True
    return getattr(member, permission, False)
Exemple #13
0
def check_user_permissions(user: User, channel: Chat) -> bool:
    user_member: ChatMember = channel.get_member(user.id)

    if user_member.status not in [user_member.ADMINISTRATOR, user_member.CREATOR]:
        raise Unauthorized('User is not an admin of the channel.')
    return True
def is_user_in_chat(chat: Chat, user_id: int) -> bool:
    member=chat.get_member(user_id)
Exemple #15
0
def can_rest(chat: Chat, user_id: int) -> bool:
    return chat.get_member(user_id).can_restrict_members