-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__init__.py
55 lines (38 loc) · 1.33 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import sys
from os.path import dirname
from adapt.intent import IntentBuilder
from mycroft.skills.core import MycroftSkill
from mycroft.util.log import getLogger
LOGGER = getLogger(__name__)
LOGGER.debug('Mycroft-Todo '+sys.version)
LOGGER.debug('Mycroft-Todo '+str(sys.path))
from .project import Project
from .task import Task
__author__ = 'gerlachry'
class TodoSkill(MycroftSkill):
def __init__(self):
super().__init__(name="TodoSkill")
def initialize(self):
add_intent = IntentBuilder("TodoIntent")\
.require("Add")\
.build()
self.register_intent(add_intent, self.handle_add)
def _get_project(self, name):
"""lookup project by name, create if not found"""
return Project(name, create=True)
def handle_add(self, message):
task = message.data.get('Task', None)
project = message.data.get('Project', None)
LOGGER.debug('adding task {0} to {1} project'.format(task, project))
try:
self.speak_dialog('add.task')
prj = self._get_project(project)
prj.add(Task(task))
prj.commit()
self.speak_dialog('add.task.complete')
except Exception as e:
LOGGER.exception("Error: {0}".format(e))
def stop(self):
pass
def create_skill():
return TodoSkill()