mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 17:33:44 +00:00
Use Response parameters.
This commit is contained in:
parent
03c5bfca5f
commit
8dbd4a2a73
2 changed files with 21 additions and 0 deletions
|
|
@ -1,3 +1,7 @@
|
||||||
|
from aiogram import types
|
||||||
|
from .utils import json
|
||||||
|
|
||||||
|
|
||||||
class ValidationError(Exception):
|
class ValidationError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -9,3 +13,18 @@ class TelegramAPIError(Exception):
|
||||||
self.method = method
|
self.method = method
|
||||||
self.status = status
|
self.status = status
|
||||||
self.body = body
|
self.body = body
|
||||||
|
|
||||||
|
def json(self):
|
||||||
|
if not self.body:
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
data = json.dumps(self.body)
|
||||||
|
except Exception:
|
||||||
|
data = None
|
||||||
|
return data
|
||||||
|
|
||||||
|
@property
|
||||||
|
def parameters(self):
|
||||||
|
data = self.json()
|
||||||
|
if data and 'parameters' in data:
|
||||||
|
return types.ResponseParameters.deserialize(data['parameters'])
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ from .order_info import OrderInfo
|
||||||
from .photo_size import PhotoSize
|
from .photo_size import PhotoSize
|
||||||
from .pre_checkout_query import PreCheckoutQuery
|
from .pre_checkout_query import PreCheckoutQuery
|
||||||
from .reply_keyboard import KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove
|
from .reply_keyboard import KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove
|
||||||
|
from .response_parameters import ResponseParameters
|
||||||
from .shipping_address import ShippingAddress
|
from .shipping_address import ShippingAddress
|
||||||
from .shipping_option import ShippingOption
|
from .shipping_option import ShippingOption
|
||||||
from .shipping_query import ShippingQuery
|
from .shipping_query import ShippingQuery
|
||||||
|
|
@ -115,6 +116,7 @@ __all__ = [
|
||||||
'PreCheckoutQuery',
|
'PreCheckoutQuery',
|
||||||
'ReplyKeyboardMarkup',
|
'ReplyKeyboardMarkup',
|
||||||
'ReplyKeyboardRemove',
|
'ReplyKeyboardRemove',
|
||||||
|
'ResponseParameters',
|
||||||
'ShippingAddress',
|
'ShippingAddress',
|
||||||
'ShippingOption',
|
'ShippingOption',
|
||||||
'ShippingQuery',
|
'ShippingQuery',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue