From d460f526336cfd3010ec55b473d7ab0363787f7a Mon Sep 17 00:00:00 2001 From: MistEO Date: Sun, 28 Aug 2022 15:42:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20python=20=E6=8E=A5=E5=8F=A3=E9=80=82?= =?UTF-8?q?=E9=85=8D=20AsstRunning=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Python/asst.py | 18 +++++++++++++++--- src/Python/sample.py | 5 +++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Python/asst.py b/src/Python/asst.py index adc566bab8..68836a0e52 100644 --- a/src/Python/asst.py +++ b/src/Python/asst.py @@ -112,10 +112,16 @@ class Asst: :return: 是否成功 """ - Asst.__lib.AsstStop.restype = ctypes.c_bool - Asst.__lib.AsstStop.argtypes = (ctypes.c_void_p,) return Asst.__lib.AsstStop(self.__ptr) + def running(self) -> bool: + """ + 是否正在运行 + + :return: 是否正在运行 + """ + return Asst.__lib.AsstRunning(self.__ptr) + @staticmethod def log(level: str, message: str) -> None: ''' @@ -132,7 +138,7 @@ class Asst: """ 获取DLL版本号 - :return: 版本号 + : return: 版本号 """ return Asst.__lib.AsstGetVersion().decode('utf-8') @@ -166,6 +172,12 @@ class Asst: Asst.__lib.AsstStart.restype = ctypes.c_bool Asst.__lib.AsstStart.argtypes = (ctypes.c_void_p,) + Asst.__lib.AsstStop.restype = ctypes.c_bool + Asst.__lib.AsstStop.argtypes = (ctypes.c_void_p,) + + Asst.__lib.AsstRunning.restype = ctypes.c_bool + Asst.__lib.AsstRunning.argtypes = (ctypes.c_void_p,) + Asst.__lib.AsstGetVersion.restype = ctypes.c_char_p Asst.__lib.AsstLog.restype = None diff --git a/src/Python/sample.py b/src/Python/sample.py index 466a1b432d..55070e161a 100644 --- a/src/Python/sample.py +++ b/src/Python/sample.py @@ -1,5 +1,6 @@ import json import pathlib +import asyncio from asst import Asst, Message @@ -64,5 +65,5 @@ if __name__ == "__main__": asst.start() - while True: - input('>') + while asst.running(): + asyncio.sleep(0)