Exemplo n.º 1
0
def can_delete(chat: Chat, bot_id: int) -> bool:
    return chat.get_member(bot_id).can_delete_messages
Exemplo n.º 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')
Exemplo n.º 3
0
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
Exemplo n.º 4
0
def bot_can_restrict(chat: Chat, bot_id: int) -> bool:
    return chat.get_member(bot_id).can_restrict_members
Exemplo n.º 5
0
def user_can_promote(chat: Chat, user: User, bot_id: int) -> bool:
    return chat.get_member(user.id).can_promote_members
Exemplo n.º 6
0
def user_can_ban(chat: Chat, user: User, bot_id: int) -> bool:
    return chat.get_member(user.id).can_restrict_members
Exemplo n.º 7
0
def user_can_pin(chat: Chat, user: User, bot_id: int) -> bool:
    return chat.get_member(user.id).can_pin_messages
Exemplo n.º 8
0
def user_can_changeinfo(chat: Chat, user: User, bot_id: int) -> bool:
    return chat.get_member(user.id).can_change_info
Exemplo n.º 9
0
def user_can_voicechat(chat: Chat, user: User, bot_id: int) -> bool:
    return chat.get_member(user.id).user_can_voice_chat
Exemplo n.º 10
0
def user_can_beanonymous(chat: Chat, user: User, bot_id: int) -> bool:
    return chat.get_member(user.id).user_can_be_anonymous
Exemplo n.º 11
0
 def from_chat(self, chat: Chat):
     chat_member: ChatMember = chat.get_member(self.user_id)
     chat_member.status
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 14
0
def is_user_in_chat(chat: Chat, user_id: int) -> bool:
    member=chat.get_member(user_id)
Exemplo n.º 15
0
def can_rest(chat: Chat, user_id: int) -> bool:
    return chat.get_member(user_id).can_restrict_members