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/daily/timer/__init__.py

32 lines
1.1 KiB
Python
Raw Normal View History

2021-08-02 18:23:11 +02:00
from lingua_franca.parse import extract_duration
2021-08-02 12:01:32 +02:00
from jarvis.skills import Skill, SkillRegistering
from jarvis.skills.decorators import intent_file_handler
2021-08-02 18:23:11 +02:00
from jarvis.utils import languages_utils
2021-08-02 12:01:32 +02:00
class TimerSkill(Skill, metaclass=SkillRegistering):
def __init__(self, data=dict):
super().__init__("TimerSkill", data)
@intent_file_handler("start_timer.intent", "StartTimerIntent")
def handle_start_timer(self, data):
print(data)
2021-08-02 18:23:11 +02:00
if 'amount' in data and 'time_unit' in data:
print(extract_duration(data['amount'] + " " + data['time_unit']), languages_utils.get_language())
if 'name' in data:
print("Start timer for {} {} named {}".format(data['amount'], data['time_unit'], data['name']))
pass
else:
print("Start timer for {} {} without name".format(data['amount'], data['time_unit']))
# TODO : ask for name
pass
else:
print("No amount and/or time_unit")
2021-08-02 12:01:32 +02:00
pass
def create_skill(data):
return TimerSkill(data)