Added option to add the current a/c to a profile

Signed-off-by: merspieler <merspieler@users.noreply.github.com>
This commit is contained in:
merspieler 2018-03-02 16:51:03 +01:00
parent fb3b9f57dc
commit 1e9396676c

View file

@ -887,9 +887,37 @@ class FlightGearCopilotSkill(MycroftSkill):
@intent_handler(IntentBuilder('AddToProfileIntent').require('conf.add.to.profile')) @intent_handler(IntentBuilder('AddToProfileIntent').require('conf.add.to.profile'))
def handle_add_to_profile_intent(self, message): def handle_add_to_profile_intent(self, message):
tn = self.connect() tn = self.connect()
# TODO add re to get the profile name # re to get the profile name
# TODO check if profile exists match = re.search("profile \.*$", message.data['utterance'], re.I)
# TODO add acid to profile if match == None:
self.speak("I didn't understand a profile name")
self.exit(tn)
# remove 'profile '
profile = re.sub("profile ", '', match)
profile_id = 0
# check if profile exists
for i_profile in self.settings['profiles']:
match = re.search(i_profile['name'], profile, re.I)
if match != None:
break
profile_id = profile_id + 1
# check if acid exists in the profile
for i_acid in i_profile['acid']:
if i_acid == acid:
self.speak("The Aircraft ID does already exsists in this profile")
self.exit(tn)
# get acid
acid = self.get_prop(tn, "/sim/aircraft")
# add acid to profile
self.settings['profiles'][profile_id]['acid'].append(acid)
self.speak("Added the aircraft to the profile")
@intent_handler(IntentBuilder('CreateProfileIntent').require('conf.create.profile')) @intent_handler(IntentBuilder('CreateProfileIntent').require('conf.create.profile'))
def handle_create_profile_intent(self, message): def handle_create_profile_intent(self, message):