mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-25 09:37:30 +00:00
🔥 Remove aiohttp
This commit is contained in:
parent
1f73588e28
commit
f401725ab0
@ -4,7 +4,6 @@ import traceback
|
||||
from typing import Optional
|
||||
|
||||
import aiofiles
|
||||
from aiohttp import ClientError, ClientConnectorError
|
||||
from httpx import HTTPError, TimeoutException
|
||||
from simnet.errors import (
|
||||
DataNotPublic,
|
||||
@ -33,7 +32,6 @@ from modules.errorpush import (
|
||||
)
|
||||
from plugins.tools.genshin import CookiesNotFoundError, PlayerNotFoundError as GenshinPlayerNotFoundError
|
||||
from utils.log import logger
|
||||
from utils.patch.aiohttp import AioHttpTimeoutException
|
||||
|
||||
try:
|
||||
import ujson as jsonlib
|
||||
@ -235,20 +233,6 @@ class ErrorHandler(Plugin):
|
||||
self.create_notice_task(update, context, notice)
|
||||
raise ApplicationHandlerStop
|
||||
|
||||
@error_handler()
|
||||
async def process_aiohttp_exception(self, update: object, context: CallbackContext):
|
||||
if not isinstance(context.error, ClientError) or not isinstance(update, Update):
|
||||
return
|
||||
exc = context.error
|
||||
notice: Optional[str] = None
|
||||
if isinstance(exc, AioHttpTimeoutException):
|
||||
notice = self.ERROR_MSG_PREFIX + " 服务器熟啦 ~ 请稍后再试"
|
||||
elif isinstance(exc, ClientConnectorError):
|
||||
notice = self.ERROR_MSG_PREFIX + " 连接服务器异常"
|
||||
if notice:
|
||||
self.create_notice_task(update, context, notice)
|
||||
raise ApplicationHandlerStop
|
||||
|
||||
@error_handler()
|
||||
async def process_player_and_cookie_not_found(self, update: object, context: CallbackContext):
|
||||
if not isinstance(
|
||||
|
@ -1,3 +1,3 @@
|
||||
from utils.patch import aiohttp, simnet
|
||||
from utils.patch import simnet
|
||||
|
||||
__all__ = ["aiohttp", "simnet"]
|
||||
__all__ = ["simnet"]
|
||||
|
@ -1,21 +0,0 @@
|
||||
import asyncio
|
||||
from typing import Optional
|
||||
|
||||
import aiohttp # pylint: disable=W0406
|
||||
from aiohttp import ClientError
|
||||
|
||||
from utils.patch.methods import patch, patchable
|
||||
|
||||
|
||||
class AioHttpTimeoutException(ClientError):
|
||||
pass
|
||||
|
||||
|
||||
@patch(aiohttp.helpers.TimerContext)
|
||||
class TimerContext:
|
||||
@patchable
|
||||
def __exit__(self, *args, **kwargs) -> Optional[bool]:
|
||||
try:
|
||||
return self.old___exit__(*args, **kwargs)
|
||||
except asyncio.TimeoutError:
|
||||
raise AioHttpTimeoutException from None
|
Loading…
Reference in New Issue
Block a user