From e41b4e80dc6a8572c2cd22047a0dee8e952e66a7 Mon Sep 17 00:00:00 2001 From: The many faced demon <154847721+themanyfaceddemon@users.noreply.github.com> Date: Thu, 12 Sep 2024 22:57:34 +0300 Subject: [PATCH] Hot fix cl_unit kwargs (#13) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Исправлен небольшой косяк при передаче параметров для _call_func в клиенте и сервере --- DMBotNetwork/main/server.py | 4 ++-- server_test.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/DMBotNetwork/main/server.py b/DMBotNetwork/main/server.py index 33c9b35..d25541b 100644 --- a/DMBotNetwork/main/server.py +++ b/DMBotNetwork/main/server.py @@ -76,10 +76,10 @@ async def _call_func( try: if inspect.iscoroutinefunction(func): - return await func(**valid_kwargs) + return await func(cl_unit=cl_unit, **valid_kwargs) else: - return func(**valid_kwargs) + return func(cl_unit=cl_unit, **valid_kwargs) except Exception as e: logger.error(f"Error calling method '{func_name}' in {cls.__name__}: {e}") diff --git a/server_test.py b/server_test.py index a52c3fe..b234276 100644 --- a/server_test.py +++ b/server_test.py @@ -5,7 +5,8 @@ class NetClassPong: - async def net_ping(self, cl_unit: ClUnit) -> None: + @staticmethod + async def net_ping(cl_unit: ClUnit) -> None: await cl_unit.send_log_info(f"Pong, {cl_unit.login}!") @@ -19,7 +20,7 @@ async def main(): base_access={}, allow_registration=False, timeout=5.0, - max_player=0, + max_player=5, ) Server.register_methods_from_class(NetClassPong)