refactor
This commit is contained in:
@ -3,7 +3,7 @@ from .base_session import BaseSession
|
||||
from .base_thon import BaseData, BaseThon
|
||||
from .json_async_converter import JsonAsyncConverter
|
||||
from .json_converter import JsonConverter
|
||||
from .models import BaseThonOptions, BaseThonSearchCodeOptions
|
||||
from .models import ThonOptions, ThonSearchCodeOptions
|
||||
|
||||
__all__ = [
|
||||
"BaseThon",
|
||||
@ -12,6 +12,6 @@ __all__ = [
|
||||
"BaseData",
|
||||
"JsonAsyncConverter",
|
||||
"AsyncBaseSession",
|
||||
"BaseThonOptions",
|
||||
"BaseThonSearchCodeOptions",
|
||||
"ThonOptions",
|
||||
"ThonSearchCodeOptions",
|
||||
]
|
||||
|
||||
@ -13,7 +13,7 @@ from telethon.tl.functions.help import GetCountriesListRequest, GetNearestDcRequ
|
||||
from telethon.tl.functions.langpack import GetLangPackRequest
|
||||
from telethon.types import JsonNumber, JsonObject, JsonObjectValue, JsonString
|
||||
|
||||
from basethon.models import BaseThonOptions, BaseThonSearchCodeOptions
|
||||
from basethon.models import ThonOptions, ThonSearchCodeOptions
|
||||
|
||||
from .constants import API_PACKS
|
||||
from .exceptions import ThonBannedError
|
||||
@ -129,7 +129,7 @@ class BaseData:
|
||||
|
||||
|
||||
class BaseThon(BaseData):
|
||||
def __init__(self, options: BaseThonOptions):
|
||||
def __init__(self, options: ThonOptions):
|
||||
self.__item = options.item
|
||||
self.__retries = options.retries
|
||||
self.__timeout = options.timeout
|
||||
@ -207,7 +207,8 @@ class BaseThon(BaseData):
|
||||
self._logger.exception(e)
|
||||
return f"ERROR_AUTH:{e}"
|
||||
|
||||
async def search_code(self, options: BaseThonSearchCodeOptions) -> str:
|
||||
async def search_code(self, options: ThonSearchCodeOptions | None = None) -> str:
|
||||
options = options or ThonSearchCodeOptions()
|
||||
future = datetime.now() + timedelta(seconds=options.wait_time)
|
||||
while future > datetime.now():
|
||||
async for message in self.client.iter_messages(
|
||||
|
||||
@ -3,7 +3,7 @@ from pathlib import Path
|
||||
|
||||
|
||||
@dataclass
|
||||
class BaseThonOptions:
|
||||
class ThonOptions:
|
||||
item: Path | None
|
||||
json_data: dict
|
||||
retries: int = 10
|
||||
@ -12,7 +12,7 @@ class BaseThonOptions:
|
||||
|
||||
|
||||
@dataclass
|
||||
class BaseThonSearchCodeOptions:
|
||||
class ThonSearchCodeOptions:
|
||||
limit: int = 1
|
||||
date_delta: int = 60
|
||||
wait_time: int = 300
|
||||
|
||||
Reference in New Issue
Block a user