mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Upgrade architecture + 5.0 Bot API (#469) * Moved `methods`, `types` and `client` to root package * Removed update handler from routers to dispatcher * Reworked events propagation mechanism to handlers * Reworked inner middlewares logic (very small change) * Updated to Bot API 5.0 * Initial migration from MkDocs to Sphinx + config for readthedocs
28 lines
750 B
Python
28 lines
750 B
Python
import datetime
|
|
from typing import Any
|
|
from unittest.mock import sentinel
|
|
|
|
from pydantic import BaseModel, Extra
|
|
|
|
from aiogram.utils.mixins import ContextInstanceMixin
|
|
|
|
|
|
class TelegramObject(ContextInstanceMixin["TelegramObject"], BaseModel):
|
|
class Config:
|
|
use_enum_values = True
|
|
orm_mode = True
|
|
extra = Extra.allow
|
|
validate_assignment = True
|
|
allow_mutation = False
|
|
allow_population_by_field_name = True
|
|
json_encoders = {datetime.datetime: lambda dt: int(dt.timestamp())}
|
|
|
|
|
|
class MutableTelegramObject(TelegramObject):
|
|
class Config:
|
|
allow_mutation = True
|
|
|
|
|
|
UNSET: Any = (
|
|
sentinel.UNSET
|
|
) # special sentinel object which used in sutuation when None might be a useful value
|