fix: 新增参数配置强制打断小爱说话
This commit is contained in:
parent
86f158532a
commit
a4ab1af160
@ -120,6 +120,9 @@ class Config:
|
|||||||
user_key_word_dict: dict[str, str] = field(
|
user_key_word_dict: dict[str, str] = field(
|
||||||
default_factory=default_user_key_word_dict
|
default_factory=default_user_key_word_dict
|
||||||
)
|
)
|
||||||
|
enable_force_stop: bool = (
|
||||||
|
os.getenv("XIAOMUSIC_ENABLE_FORCE_STOP", "false").lower() == "true"
|
||||||
|
)
|
||||||
|
|
||||||
def append_keyword(self, keys, action):
|
def append_keyword(self, keys, action):
|
||||||
for key in keys.split(","):
|
for key in keys.split(","):
|
||||||
|
@ -344,11 +344,11 @@ class XiaoMusic:
|
|||||||
|
|
||||||
async def stop_if_xiaoai_is_playing(self, device_id):
|
async def stop_if_xiaoai_is_playing(self, device_id):
|
||||||
is_playing = await self.get_if_xiaoai_is_playing(device_id)
|
is_playing = await self.get_if_xiaoai_is_playing(device_id)
|
||||||
if is_playing:
|
if is_playing or self.config.enable_force_stop:
|
||||||
# stop it
|
# stop it
|
||||||
ret = await self.mina_service.player_stop(device_id)
|
ret = await self.mina_service.player_stop(device_id)
|
||||||
self.log.info(
|
self.log.info(
|
||||||
f"stop_if_xiaoai_is_playing player_stop device_id:{device_id} ret:{ret}"
|
f"stop_if_xiaoai_is_playing player_stop device_id:{device_id} enable_force_stop:{self.config.enable_force_stop} ret:{ret}"
|
||||||
)
|
)
|
||||||
|
|
||||||
async def force_stop_one_xiaoai(self, device_id):
|
async def force_stop_one_xiaoai(self, device_id):
|
||||||
|
Loading…
Reference in New Issue
Block a user