RoboWaiter/robowaiter/behavior_lib/cond/Chatting.py

34 lines
1.0 KiB
Python
Raw Normal View History

import py_trees as ptree
from typing import Any
2023-11-08 15:28:01 +08:00
from robowaiter.behavior_lib._base.Cond import Cond
2023-11-20 14:23:26 +08:00
class Chatting(Cond):
2023-11-08 15:28:01 +08:00
def __init__(self):
super().__init__()
def _update(self) -> ptree.common.Status:
# if self.scene.status?
if self.scene.state['chat_list'] == []:
return ptree.common.Status.FAILURE
2023-11-18 14:13:07 +08:00
name,sentence = self.scene.state['chat_list'][0]
2023-11-20 14:23:26 +08:00
if name == "Goal":
return ptree.common.Status.SUCCESS
2023-11-18 14:13:07 +08:00
if "customer" in self.scene.state["attention"]:
attention_customer = self.scene.state["attention"]["customer"]
if name == attention_customer:
return ptree.common.Status.SUCCESS
else:
2023-11-19 17:42:56 +08:00
# self.scene.chat_bubble("请稍等一下") # 机器人输出对话
# self.scene.wait_history.add(sentence)
2023-11-18 14:13:07 +08:00
return ptree.common.Status.FAILURE
else:
2023-11-18 14:13:07 +08:00
self.scene.state["attention"]["customer"] = name
return ptree.common.Status.SUCCESS