diff --git a/aiogram/bot/api.py b/aiogram/bot/api.py index 1d0c4f7b..cb258cdf 100644 --- a/aiogram/bot/api.py +++ b/aiogram/bot/api.py @@ -80,7 +80,7 @@ def check_result(method_name: str, content_type: str, status_code: int, body: st exceptions.NotFound.detect(description) elif status_code == HTTPStatus.CONFLICT: exceptions.ConflictError.detect(description) - elif status_code in [HTTPStatus.UNAUTHORIZED, HTTPStatus.FORBIDDEN]: + elif status_code in (HTTPStatus.UNAUTHORIZED, HTTPStatus.FORBIDDEN): exceptions.Unauthorized.detect(description) elif status_code == HTTPStatus.REQUEST_ENTITY_TOO_LARGE: raise exceptions.NetworkError('File too large for uploading. ' diff --git a/aiogram/bot/bot.py b/aiogram/bot/bot.py index f427fa8c..c5678a37 100644 --- a/aiogram/bot/bot.py +++ b/aiogram/bot/bot.py @@ -1135,10 +1135,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): permissions = prepare_arg(permissions) payload = generate_payload(**locals()) - for permission in ['can_send_messages', + for permission in ('can_send_messages', 'can_send_media_messages', 'can_send_other_messages', - 'can_add_web_page_previews']: + 'can_add_web_page_previews'): if permission in payload: warnings.warn(f"The method `restrict_chat_member` now takes the new user permissions " f"in a single argument of the type ChatPermissions instead of " diff --git a/aiogram/types/chat_member.py b/aiogram/types/chat_member.py index 347b2750..274c8a26 100644 --- a/aiogram/types/chat_member.py +++ b/aiogram/types/chat_member.py @@ -34,6 +34,9 @@ class ChatMember(base.TelegramObject): can_send_other_messages: base.Boolean = fields.Field() can_add_web_page_previews: base.Boolean = fields.Field() + def is_chat_creator(self) -> bool: + return ChatMemberStatus.is_chat_creator(self.status) + def is_chat_admin(self) -> bool: return ChatMemberStatus.is_chat_admin(self.status) @@ -57,10 +60,14 @@ class ChatMemberStatus(helper.Helper): LEFT = helper.Item() # left KICKED = helper.Item() # kicked + @classmethod + def is_chat_creator(cls, role: str) -> bool: + return role == cls.CREATOR + @classmethod def is_chat_admin(cls, role: str) -> bool: - return role in [cls.ADMINISTRATOR, cls.CREATOR] + return role in (cls.ADMINISTRATOR, cls.CREATOR) @classmethod def is_chat_member(cls, role: str) -> bool: - return role in [cls.MEMBER, cls.ADMINISTRATOR, cls.CREATOR, cls.RESTRICTED] + return role in (cls.MEMBER, cls.ADMINISTRATOR, cls.CREATOR, cls.RESTRICTED) diff --git a/aiogram/types/input_media.py b/aiogram/types/input_media.py index 9a77658f..25422df1 100644 --- a/aiogram/types/input_media.py +++ b/aiogram/types/input_media.py @@ -239,7 +239,7 @@ class MediaGroup(base.TelegramObject): elif not isinstance(media, InputMedia): raise TypeError(f"Media must be an instance of InputMedia or dict, not {type(media).__name__}") - elif media.type in ['document', 'audio', 'animation']: + elif media.type in ('document', 'audio', 'animation'): raise ValueError(f"This type of media is not supported by media groups!") self.media.append(media)