Added support async command

This commit is contained in:
Maxim Khomutov 2023-07-26 22:37:32 +03:00
parent 7e0c50a04e
commit 6dd3de63a9

View File

@ -7,6 +7,7 @@
# Licence: FPA # Licence: FPA
# (c) kuitoi.su 2023 # (c) kuitoi.su 2023
import builtins import builtins
import inspect
import logging import logging
from typing import AnyStr from typing import AnyStr
@ -242,7 +243,11 @@ class Console:
self.log(text) self.log(text)
command_object = self.__func.get(cmd) command_object = self.__func.get(cmd)
if command_object: if command_object:
out = command_object['f'](cmd_s[1:]) func = command_object['f']
if inspect.iscoroutinefunction(func):
out = await func(cmd_s[1:])
else:
out = func(cmd_s[1:])
if out: if out:
self.log(out) self.log(out)
else: else: