mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Fix #117: TypeError with LazyProxy object in keyboards
This commit is contained in:
parent
f228329b01
commit
25bdb9cf4d
2 changed files with 8 additions and 0 deletions
|
|
@ -4,6 +4,8 @@ import io
|
|||
import typing
|
||||
from typing import TypeVar
|
||||
|
||||
from babel.support import LazyProxy
|
||||
|
||||
from .fields import BaseField
|
||||
from ..utils import json
|
||||
from ..utils.mixins import ContextInstanceMixin
|
||||
|
|
@ -163,6 +165,8 @@ class TelegramObject(ContextInstanceMixin, metaclass=MetaTelegramObject):
|
|||
value = self.props[name].export(self)
|
||||
if isinstance(value, TelegramObject):
|
||||
value = value.to_python()
|
||||
if isinstance(value, LazyProxy):
|
||||
value = str(value)
|
||||
result[self.props_aliases.get(name, name)] = value
|
||||
return result
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import datetime
|
||||
import secrets
|
||||
|
||||
from babel.support import LazyProxy
|
||||
|
||||
from aiogram import types
|
||||
from . import json
|
||||
|
||||
|
|
@ -57,6 +59,8 @@ def prepare_arg(value):
|
|||
return int((now + value).timestamp())
|
||||
elif isinstance(value, datetime.datetime):
|
||||
return round(value.timestamp())
|
||||
elif isinstance(value, LazyProxy):
|
||||
return str(value)
|
||||
return value
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue