mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 02:03:04 +00:00
Small fixes
This commit is contained in:
parent
0d6af5bc8d
commit
cc8511284f
3 changed files with 6 additions and 2 deletions
|
|
@ -1,4 +1,6 @@
|
||||||
|
import datetime
|
||||||
import json
|
import json
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
class Serializable:
|
class Serializable:
|
||||||
|
|
@ -26,6 +28,8 @@ class Deserializable:
|
||||||
continue
|
continue
|
||||||
if hasattr(attr, 'to_json'):
|
if hasattr(attr, 'to_json'):
|
||||||
attr = getattr(attr, 'to_json')()
|
attr = getattr(attr, 'to_json')()
|
||||||
|
elif isinstance(attr, datetime.datetime):
|
||||||
|
attr = int(time.mktime(attr.timetuple()))
|
||||||
result[item] = attr
|
result[item] = attr
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ from . import Deserializable
|
||||||
|
|
||||||
|
|
||||||
class CallbackQuery(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):
|
def __init__(self, id, from_user, message, inline_message_id, chat_instance, data, game_short_name):
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ from .user import User
|
||||||
|
|
||||||
class Message(Deserializable):
|
class Message(Deserializable):
|
||||||
__slots__ = (
|
__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',
|
'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',
|
'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',
|
'new_chat_member', 'left_chat_member', 'new_chat_title', 'new_chat_photo', 'delete_chat_photo',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue