-
Notifications
You must be signed in to change notification settings - Fork 1
/
__init__.py
39 lines (29 loc) · 1.61 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
from mycroft.skills.core import (MycroftSkill, intent_handler, intent_file_handler)
from .zipcoderequest import get_zip_from_ip, get_my_ip
from .allergyrequest import get_allergy_index_for_day
class AllergyLevel(MycroftSkill):
def __init__(self):
MycroftSkill.__init__(self)
def initialize(self):
self.zipcode = self.settings.get('zipcode')
if self.zipcode is None:
ipaddress = get_my_ip()
self.zipcode = get_zip_from_ip(ipaddress)
self.settings['zipcode'] = self.zipcode
@intent_file_handler('level.allergy.today.intent')
def handle_level_allergy_today_intent(self, message):
allergy_index_for_today, allergy_level_for_today = get_allergy_index_for_day(day='today', zipcode=self.zipcode)
self.speak_dialog('level.allergy', {"allergy_index": allergy_index_for_today,
"allergy_level": allergy_level_for_today,
"zipcode": self.zipcode, "day": "today"})
pass
@intent_file_handler('level.allergy.tomorrow.intent')
def handle_level_allergy_tomorrow_intent(self, message):
allergy_index_for_tomorrow, allergy_level_for_tomorrow = get_allergy_index_for_day(day='tomorrow', zipcode=self.zipcode)
self.speak_dialog('level.allergy', {"allergy_index": allergy_index_for_tomorrow,
"allergy_level": allergy_level_for_tomorrow,
"zipcode": self.zipcode, "day": "tomorrow"})
def stop(self):
pass
def create_skill():
return AllergyLevel()