class EventChat:
# Funnel input to a unique response bundle
def __init__(self, ur: UniqueResponder, *args):
self._dic = {arg: ur for arg in args}
def add_items(self, ur: UniqueResponder, *args):
for arg in args:
self._dic[arg] = ur
def add_key_value(self, key: str, value: str):
if key in self._dic:
self._dic[key].addResponse(value)
else:
self._dic[key] = UniqueResponder(value)
def response(self, in1: str) -> str:
return self._dic[in1].getAResponse() if in1 in self._dic else ""
class DiEvent(Skill):
def __init__(self):
super().__init__()
self._e = False
self.declarations = UniqueResponder("put on your nappy", "it is diaper time my little bed wetter","put on your diaper", "diaper your butt so you do not have an accident")
self.convo1 = EventChat(UniqueResponder("you are wearing your diaper","it is not a debate sweety","you need your nappy", "you know you need a diaper"),"i will not wet","i am not wearing a diaper","i am a big boy", "i do not need a diaper","i promise not to wet")
self.convo2 = EventChat(UniqueResponder("good boy","good", "i am proud of you"),"i wore a diaper","i wore a nappy")
# override
def input(self, ear: str, skin: str, eye: str):
if not len(ear)>5 :
return
if not TimeUtils.getHoursAsInt() == 19:
self._e = False;return
# time of event:
if not self._e:
self.setSimpleAlg(self.declarations.getAResponse());self._e = True; return
n = self.convo1.response(ear)
if len(n) > 0:
self.setSimpleAlg(n)
return
n = self.convo2.response(ear)
if len(n) > 0:
self.setSimpleAlg(n)
class DiEvent(Skill):
def __init__(self):
super().__init__()
self._e = False
self.declarations = UniqueResponder("put on your nappy", "it is diaper time my little bed wetter","put on your diaper", "diaper your butt so you do not have an accident")
self.convo1 = EventChat(UniqueResponder("you are wearing your diaper","it is not a debate sweety","you need your nappy", "you know you need a diaper"),"i will not wet","i am not wearing a diaper","i am a big boy", "i do not need a diaper","i promise not to wet")
self.convo1.add_items(UniqueResponder("good boy","good", "i am proud of you"),"i wore a diaper","i wore a nappy")
# override
def input(self, ear: str, skin: str, eye: str):
if not len(ear)>5 :
return
# event reset
if not TimeUtils.getHoursAsInt() == 22:
self._e = False;return
# time of event:
if not self._e:
self.setSimpleAlg(self.declarations.getAResponse());self._e = True; return
n = self.convo1.response(ear)
if len(n) > 0:
self.setSimpleAlg(n)
return
self.convo1.add_items(UniqueResponder("you are being responsible", "you are doing the right thing", "you are making a good choice"), "i will wear a diaper", "i will wear a nappy")
self.convo1.add_items(UniqueResponder("that's the spirit", "you are a big help", "you are doing great"), "i will put on a diaper", "i will put on a nappy")