diff --git a/aiogram/types/__init__.py b/aiogram/types/__init__.py index dad21861..afecda8c 100644 --- a/aiogram/types/__init__.py +++ b/aiogram/types/__init__.py @@ -1,4 +1,6 @@ +import datetime import json +import time class Serializable: @@ -26,6 +28,8 @@ class Deserializable: continue if hasattr(attr, 'to_json'): attr = getattr(attr, 'to_json')() + elif isinstance(attr, datetime.datetime): + attr = int(time.mktime(attr.timetuple())) result[item] = attr return result diff --git a/aiogram/types/callback_query.py b/aiogram/types/callback_query.py index a7db0d17..db7bdea1 100644 --- a/aiogram/types/callback_query.py +++ b/aiogram/types/callback_query.py @@ -2,7 +2,7 @@ from . import Deserializable class CallbackQuery(Deserializable): - __slots__ = ('id', 'from', 'message', 'inline_message_id', 'chat_instance', 'data', 'game_short_name') + __slots__ = ('id', 'from_user', 'message', 'inline_message_id', 'chat_instance', 'data', 'game_short_name') def __init__(self, id, from_user, message, inline_message_id, chat_instance, data, game_short_name): self.data = data diff --git a/aiogram/types/message.py b/aiogram/types/message.py index 4588e4f2..46a1852a 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -8,7 +8,7 @@ from .user import User class Message(Deserializable): __slots__ = ( - 'message_id', 'from', 'date', 'chat', 'forward_from', 'forward_from_chat', 'forward_from_message_id', + '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', 'video', 'voice', 'video_note', 'new_chat_members', 'caption', 'contact', 'location', 'venue', 'new_chat_member', 'left_chat_member', 'new_chat_title', 'new_chat_photo', 'delete_chat_photo',