This repository has been archived on 2023-06-09. You can view files and clone it, but cannot push or open issues or pull requests.
jarvis-server/jarvis/skills/entertainement/decide/__init__.py

28 lines
720 B
Python
Raw Normal View History

2021-08-01 21:07:03 +02:00
import random
from jarvis.skills import Skill, SkillRegistering
2021-09-08 14:53:27 +02:00
from jarvis.skills.decorators import intent_file_handler
2021-08-01 21:07:03 +02:00
class DecideSkill(Skill, metaclass=SkillRegistering):
def __init__(self, data=dict):
super().__init__("DecideSkill", data)
2021-09-08 14:53:27 +02:00
@intent_file_handler("decide.intent", "DecideIntent")
def handle_decide_intent(self, data):
2021-08-01 21:07:03 +02:00
print("decide")
if 'choice1' in data and 'choice2' in data:
choice = bool(random.getrandbits(1))
if choice:
self.speak(data['choice1'])
else:
self.speak(data['choice2'])
else:
print("no all choice")
def create_skill(data):
return DecideSkill(data)