From c9e7be97f23b78c443eeb6b56b750e372da509eb Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Fri, 4 Aug 2017 14:08:51 +0300 Subject: [PATCH] Fix f70d45c & e90ca7c --- aiogram/dispatcher/filters.py | 2 +- aiogram/types/message.py | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/aiogram/dispatcher/filters.py b/aiogram/dispatcher/filters.py index d77a6378..63d222d5 100644 --- a/aiogram/dispatcher/filters.py +++ b/aiogram/dispatcher/filters.py @@ -81,7 +81,7 @@ class ContentTypeFilter(Filter): self.content_types = content_types def check(self, message): - return message.content_type[0] in self.content_types + return message.content_type in self.content_types class CancelFilter(Filter): diff --git a/aiogram/types/message.py b/aiogram/types/message.py index d474da95..3a4d6a97 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -118,33 +118,32 @@ class Message(Deserializable): invoice = Invoice.deserialize(raw_data.get('invoice')) successful_payment = SuccessfulPayment.deserialize(raw_data.get('successful_payment')) - # TODO: ContentType helper always return list. Don't forget that! (Fix it after merging fsm into dev branch) if text: - content_type = ContentType.TEXT + content_type = ContentType.TEXT[0] elif audio: - content_type = ContentType.AUDIO + content_type = ContentType.AUDIO[0] elif document: - content_type = ContentType.DOCUMENT + content_type = ContentType.DOCUMENT[0] elif game: - content_type = ContentType.GAME + content_type = ContentType.GAME[0] elif photo: - content_type = ContentType.PHOTO + content_type = ContentType.PHOTO[0] elif sticker: - content_type = ContentType.STICKER + content_type = ContentType.STICKER[0] elif video: - content_type = ContentType.VIDEO + content_type = ContentType.VIDEO[0] elif voice: - content_type = ContentType.VOICE + content_type = ContentType.VOICE[0] elif new_chat_members: - content_type = ContentType.NEW_CHAT_MEMBERS + content_type = ContentType.NEW_CHAT_MEMBERS[0] elif left_chat_member: - content_type = ContentType.LEFT_CHAT_MEMBER + content_type = ContentType.LEFT_CHAT_MEMBER[0] elif invoice: - content_type = ContentType.INVOICE + content_type = ContentType.INVOICE[0] elif successful_payment: - content_type = ContentType.SUCCESSFUL_PAYMENT + content_type = ContentType.SUCCESSFUL_PAYMENT[0] else: - content_type = ContentType.UNKNOWN + content_type = ContentType.UNKNOWN[0] return Message(message_id, from_user, date, chat, forward_from, forward_from_chat, forward_from_message_id, forward_date, reply_to_message, edit_date, text, entities, audio, document, game, photo, sticker,