Merge pull request #34 from DarkCat09/darkcat09-patch1
Fixed some bugs, changed tests structure, mypy
This commit is contained in:
commit
7f77478164
11 changed files with 178 additions and 38 deletions
|
@ -295,12 +295,15 @@ class AternosConfig:
|
|||
:rtype: Dict[str,Any]
|
||||
"""
|
||||
|
||||
self.__get_all_props(
|
||||
return self.__get_all_props(
|
||||
f'https://aternos.org/files/{world}/level.dat',
|
||||
proptyping, [DAT_PREFIX, DAT_GR_PREFIX]
|
||||
)
|
||||
|
||||
def set_world_props(self, props: Dict[str, Any]) -> None:
|
||||
def set_world_props(
|
||||
self,
|
||||
props: Dict[Union[WorldOpts, WorldRules], Any]) -> None:
|
||||
|
||||
for key in props:
|
||||
self.set_world_prop(key, props[key])
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ class AternosConnect:
|
|||
|
||||
if '<title>Please Wait... | Cloudflare</title>' in req.text:
|
||||
logging.info('Retrying to bypass Cloudflare')
|
||||
self.request_cloudflare(
|
||||
return self.request_cloudflare(
|
||||
url, method,
|
||||
params, data,
|
||||
headers, reqcookies,
|
||||
|
@ -244,6 +244,7 @@ class AternosConnect:
|
|||
retry - 1
|
||||
)
|
||||
|
||||
logging.debug('AternosConnect received: ' + req.text[:65])
|
||||
logging.info(
|
||||
f'{method} completed with {req.status_code} status'
|
||||
)
|
||||
|
|
|
@ -49,7 +49,7 @@ class FileManager:
|
|||
else FileType.directory
|
||||
|
||||
fsize_raw = f.xpath('./div[@class="filesize"]')
|
||||
fsize = 0
|
||||
fsize = 0.0
|
||||
if len(fsize_raw) > 0:
|
||||
|
||||
fsize_text = fsize_raw[0].text.strip()
|
||||
|
|
|
@ -3,6 +3,7 @@ import lxml.html
|
|||
from typing import List, Union
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from .atserver import Edition
|
||||
if TYPE_CHECKING:
|
||||
from .atserver import AternosServer
|
||||
|
||||
|
@ -12,6 +13,8 @@ class Lists(enum.Enum):
|
|||
"""Players list type enum"""
|
||||
|
||||
whl = 'whitelist'
|
||||
whl_je = 'whitelist'
|
||||
whl_be = 'allowlist'
|
||||
ops = 'ops'
|
||||
ban = 'banned-players'
|
||||
ips = 'banned-ips'
|
||||
|
@ -32,7 +35,13 @@ class PlayersList:
|
|||
|
||||
self.atserv = atserv
|
||||
self.lst = Lists(lst)
|
||||
self.players = []
|
||||
|
||||
common_whl = (self.lst == Lists.whl)
|
||||
bedrock = (atserv.edition == Edition.bedrock)
|
||||
if common_whl and bedrock:
|
||||
self.lst = Lists.whl_be
|
||||
|
||||
self.players: List[str] = []
|
||||
self.parsed = False
|
||||
|
||||
def list_players(self, cache: bool = True) -> List[str]:
|
||||
|
|
|
@ -10,6 +10,8 @@ from .atconnect import REQUA
|
|||
if TYPE_CHECKING:
|
||||
from .atserver import AternosServer
|
||||
|
||||
FunctionT = Callable[[Any], Coroutine[Any, Any, None]]
|
||||
|
||||
|
||||
class Streams(enum.Enum):
|
||||
|
||||
|
@ -44,7 +46,8 @@ class AternosWss:
|
|||
self.cookies = atserv.atconn.session.cookies
|
||||
self.session = self.cookies['ATERNOS_SESSION']
|
||||
self.servid = atserv.servid
|
||||
self.recv = {}
|
||||
recvtype = Dict[Streams, Tuple[FunctionT, Tuple[Any]]]
|
||||
self.recv: recvtype = {}
|
||||
self.autoconfirm = autoconfirm
|
||||
self.confirmed = False
|
||||
|
||||
|
@ -54,7 +57,7 @@ class AternosWss:
|
|||
|
||||
self.atserv.confirm()
|
||||
|
||||
def wssreceiver(self, stream: Streams, *args: Any) -> Callable[[Callable[[Any], Coroutine[Any, Any, None]]], Any]:
|
||||
def wssreceiver(self, stream: Streams, *args: Any) -> Callable[[FunctionT], Any]:
|
||||
|
||||
"""Decorator that marks your function as a stream receiver.
|
||||
When websocket receives message from the specified stream,
|
||||
|
@ -68,7 +71,7 @@ class AternosWss:
|
|||
:rtype: Callable[[Callable[[Any], Coroutine[Any, Any, None]]], Any]
|
||||
"""
|
||||
|
||||
def decorator(func: Callable[[Any], Coroutine[Any, Any, None]]) -> None:
|
||||
def decorator(func: FunctionT) -> None:
|
||||
self.recv[stream] = (func, args)
|
||||
return decorator
|
||||
|
||||
|
|
Reference in a new issue