mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-06 07:50:32 +00:00
Small fix
This commit is contained in:
parent
d2c99fccf4
commit
0ae4f6d948
7 changed files with 19 additions and 5 deletions
|
|
@ -4,6 +4,7 @@ import os
|
|||
import aiohttp
|
||||
|
||||
from ..exceptions import ValidationError, TelegramAPIError
|
||||
from ..utils import json
|
||||
|
||||
log = logging.getLogger('aiogram')
|
||||
|
||||
|
|
@ -40,7 +41,7 @@ async def _check_result(method_name, response):
|
|||
raise TelegramAPIError(f"The server returned HTTP {response.status}. Response body:\n[{body}]",
|
||||
method_name, response.status, body)
|
||||
|
||||
result_json = await response.json()
|
||||
result_json = await response.json(loads=json.loads)
|
||||
|
||||
if not result_json.get('ok'):
|
||||
body = await response.text()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import asyncio
|
||||
import io
|
||||
import json
|
||||
|
||||
import aiohttp
|
||||
|
||||
from . import api
|
||||
from ..utils import json
|
||||
from ..utils.payload import generate_payload
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import datetime
|
||||
import json
|
||||
from ..utils import json
|
||||
import time
|
||||
|
||||
from .base import BaseBot
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
class Dispatcher:
|
||||
def __init__(self, bot, loop=None):
|
||||
self.bot: Bot = bot
|
||||
self.bot: 'Bot' = bot
|
||||
if loop is None:
|
||||
loop = self.bot.loop
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from . import ChatPhoto
|
||||
from .chat_photo import ChatPhoto
|
||||
from .base import Deserializable
|
||||
|
||||
|
||||
|
|
|
|||
12
aiogram/utils/json.py
Normal file
12
aiogram/utils/json.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
try:
|
||||
import ujson as json
|
||||
except ImportError:
|
||||
import json
|
||||
|
||||
|
||||
def dumps(data):
|
||||
return json.dumps(data)
|
||||
|
||||
|
||||
def loads(data):
|
||||
return json.loads(data)
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
ujson
|
||||
aiohttp>=2.1.0
|
||||
appdirs>=1.4.3
|
||||
async-timeout>=1.2.1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue