From 47a865aa5f4864888e698ec43a9a6c7695a6e317 Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Sat, 27 Jan 2018 08:15:34 +0200 Subject: [PATCH] More usable ChatType checker. Allow to use message or chat instances. --- aiogram/types/chat.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aiogram/types/chat.py b/aiogram/types/chat.py index e86936d4..dcb38876 100644 --- a/aiogram/types/chat.py +++ b/aiogram/types/chat.py @@ -384,9 +384,11 @@ class ChatType(helper.Helper): @staticmethod def _check(obj, chat_types) -> bool: - if not hasattr(obj, 'chat'): + if hasattr(obj, 'chat'): + obj = obj.chat + if not hasattr(obj, 'type'): return False - return obj.chat.type in chat_types + return obj.type in chat_types @classmethod def is_private(cls, obj) -> bool: