def volume_set(self, message): placement = message.data.get('placement') placement = self.check_placement(placement) vol = message.data.get('pos_nr') vol = extract_number(vol) vol = int(vol) self.set_vol(placement, vol)
def handle_switch_to_pos(self, message): pos = message.data.get('pos_nr') placement = message.data.get('placement') placement = self.check_placement(placement) pos = extract_number(pos) pos = int(pos) self.switch_to_pos(placement, pos)
def handle_playlist_replace_and_play(self, message): playlist = message.data.get('playlist') placement = message.data.get('placement') placement = self.check_placement(placement) pos = message.data.get('pos_nr') pos = extract_number(pos) pos = int(pos) self.playlist_replace_and_play(placement, playlist, pos)
def handle_search_current_playlist(self, message): placement = message.data.get('placement') placement = self.check_placement(placement) query = message.data.get('query') answer = self.search_in_current_playlist(placement, query) if answer != 0: play_title = self.ask_yesno('to_play') if play_title == 'yes': pos_nr = self.get_response('which_position_to_play') pos_nr = extract_number(pos_nr) self.switch_to_pos(placement, pos_nr) elif play_title == 'no': pass else: self.speak_dialog('some_error') else: self.speak(answer)
def handle_database_dialog(self, message): placement = message.data.get('placement') placement = self.check_placement(placement) query = message.data.get('query') query_dict = { 'query': query } query_correct = self.ask_yesno('feedback_query', query_dict) if query_correct == 'yes': selection = self.get_response('which_data_field') if self.voc_match(selection, 'artist'): selection = 'artist' elif self.voc_match(selection, 'title'): selection = 'title' elif self.voc_match(selection, 'album'): selection = 'album' elif self.voc_match(selection, 'genre'): selection = 'genre' else: self.speak_dialog('missunderstand_selection') else: self.speak_dialog('missunderstand_query') if selection == 'artist' or selection == 'title' or selection == 'album' or selection == 'genre': placement = self.check_placement(placement) search_result = self.search_only_in_database( placement, query, selection) numbers_result = search_result[1] if numbers_result != 0: title = self.get_response('which_title_to_play', {'numbers': numbers_result}) if self.voc_match(title, 'nothing'): pass elif self.voc_match(title, 'all'): title = 0 self.play_from_database_search(placement, search_result[0], title) else: title = extract_number(title) title = int(title) - 1 self.play_from_database_search(placement, search_result[0], title) else: self.speak_dialog('no_result', { 'query': query, 'selection': selection })
def handle_search_in_database(self, message): placement = message.data.get('placement') placement = self.check_placement(placement) query = message.data.get('query') query_dict = { 'query': query } pos_nr = message.data.get('pos_nr') pos_nr = extract_number(pos_nr) query_correct = self.ask_yesno('feedback_query', query_dict) if query_correct == 'yes': selection = self.get_response('which_data_field') if self.voc_match(selection, 'artist'): selection = 'artist' elif self.voc_match(selection, 'title'): selection = 'title' elif self.voc_match(selection, 'album'): selection = 'album' elif self.voc_match(selection, 'genre'): selection = 'genre' else: self.speak_dialog('missunderstand_selection') if pos_nr == "": pos_nr = '0' self.search_in_database_and_play(placement, query, selection, pos_nr) else: pass
def things_control(self,msg): utterance = msg.data["utterance"] number = str(extract_number(utterance)) if "lights" in msg.data.get('utterance') or "light" in msg.data.get('utterance'): if "green" in msg.data.get('utterance'): if "kitchen" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Color", "120,100,100") self.speak_dialog("BlindsAdjust") if "living room" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Color", "120,100,100") self.speak_dialog("BlindsAdjust") elif "room" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Color", "120,100,100") self.speak_dialog("BlindsAdjust") if "red" in msg.data.get('utterance'): if "kitchen" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Color", "0,100,100") self.speak_dialog("BlindsAdjust") if "living room" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Color", "0,100,100") self.speak_dialog("BlindsAdjust") elif "room" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Color", "0,100,100") self.speak_dialog("BlindsAdjust") if "blue" in msg.data.get('utterance'): if "kitchen" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Color", "202,100,100") self.speak_dialog("BlindsAdjust") if "living room" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Color", "202,100,100") self.speak_dialog("BlindsAdjust") elif "room" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Color", "202,100,100") self.speak_dialog("BlindsAdjust") if "yellow" in msg.data.get('utterance'): if "kitchen" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Color", "46,99,100") self.speak_dialog("BlindsAdjust") if "living room" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Color", "46,99,100") self.speak_dialog("BlindsAdjust") elif "room" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Color", "46,99,100") self.speak_dialog("BlindsAdjust") if "orange" in msg.data.get('utterance'): if "kitchen" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Color", "27,100,100") self.speak_dialog("BlindsAdjust") if "living room" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Color", "27,100,100") self.speak_dialog("BlindsAdjust") elif "room" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Color", "27,100,100") self.speak_dialog("BlindsAdjust") if "pink" in msg.data.get('utterance'): if "kitchen" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Color", "326,100,100") self.speak_dialog("BlindsAdjust") if "living room" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Color", "326,100,100") self.speak_dialog("BlindsAdjust") elif "room" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Color", "326,100,100") self.speak_dialog("BlindsAdjust") if "purple" in msg.data.get('utterance'): if "kitchen" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Color", "263,78,100") self.speak_dialog("BlindsAdjust") if "living room" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Color", "263,78,100") self.speak_dialog("BlindsAdjust") elif "room" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Color", "263,78,100") self.speak_dialog("BlindsAdjust") if "white" in msg.data.get('utterance'): if "kitchen" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Color", "191,1,100") self.speak_dialog("BlindsAdjust") if "living room" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Color", "191,1,100") self.speak_dialog("BlindsAdjust") elif "room" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Color", "191,1,100") self.speak_dialog("BlindsAdjust") else: #si el número es distinto de null if "kitchen" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Dimmer", number) self.speak_dialog("BlindsAdjust") if "living room" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Dimmer", number) self.speak_dialog("BlindsAdjust") elif "room" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Dimmer", number) self.speak_dialog("BlindsAdjust") if "blinds" in msg.data.get('utterance') or "shutters" in msg.data.get('utterance') or "blind" in msg.data.get('utterance'): if "kitchen" in msg.data.get('utterance'): if "up" in msg.data.get('utterance') or "raise" in msg.data.get('utterance') : self.send_post_openhab("Kuche_Jalousie1", "0") self.send_post_openhab("Kuche_Jalousie2", "0") self.speak_dialog("BlindsUp") if "down" in msg.data.get('utterance') or "lower" in msg.data.get('utterance'): self.send_post_openhab("Kuche_Jalousie1", "100") self.send_post_openhab("Kuche_Jalousie2", "100") self.speak_dialog("BlindsDown") elif "to" in msg.data.get('utterance') or "as" in msg.data.get('utterance'): self.send_post_openhab("Kuche_Jalousie1", number) self.send_post_openhab("Kuche_Jalousie2", number) self.speak_dialog("BlindsAdjust") if "living room" in msg.data.get('utterance'): if "up" in msg.data.get('utterance') or "raise" in msg.data.get('utterance'): self.send_post_openhab("WZ_Jalousien", "0") self.speak_dialog("BlindsUp") if "down" in msg.data.get('utterance') or "lower" in msg.data.get('utterance'): self.send_post_openhab("WZ_Jalousien", "100") self.speak_dialog("BlindsDown") elif "to" in msg.data.get('utterance'): self.send_post_openhab("WZ_Jalousien", number) self.speak_dialog("BlindsAdjust") if "all" in msg.data.get('utterance') or "house" in msg.data.get('utterance') or "home" in msg.data.get('utterance'): if "up" in msg.data.get('utterance') or "raise" in msg.data.get('utterance'): self.send_post_openhab("Wohnung_Jalousien", "0") self.speak_dialog("BlindsUp") if "down" in msg.data.get('utterance') or "lower" in msg.data.get('utterance'): self.send_post_openhab("Wohnung_Jalousien", "100") self.speak_dialog("BlindsDown") elif "to" in msg.data.get('utterance'): self.send_post_openhab("Wohnung_Jalousien", number) self.speak_dialog("BlindsAdjust") if "music" in msg.data.get('utterance') or "stereo" in msg.data.get('utterance') or "yamaha" in msg.data.get('utterance') or "sound system" in msg.data.get('utterance') or "radio" in msg.data.get('utterance'): if "source" in msg.data.get('utterance') or "function" in msg.data.get('utterance') or "mode" in msg.data.get('utterance'): if "bluetooth" in msg.data.get('utterance'): self.send_post_openhab("RXV685Main_Zone_Zone_channels_", "Bluetooth") self.speak_dialog("BlindsAdjust") if "tuner" in msg.data.get('utterance') or "radio" in msg.data.get('utterance'): self.send_post_openhab("RXV685Main_Zone_Zone_channels_", "Tuner") self.speak_dialog("BlindsAdjust") if "auxiliar" in msg.data.get('utterance') or "aux" in msg.data.get('utterance'): self.send_post_openhab("RXV685Main_Zone_Zone_channels_", "aux") self.speak_dialog("BlindsAdjust") if "net radio" in msg.data.get('utterance'): self.send_post_openhab("RXV685Main_Zone_Zone_channels_", "NET RADIO") self.speak_dialog("BlindsAdjust") if "cd" in msg.data.get('utterance'): self.send_post_openhab("RXV685Main_Zone_Zone_channels_", "CD") self.speak_dialog("BlindsAdjust") if "usb" in msg.data.get('utterance'): self.send_post_openhab("RXV685Main_Zone_Zone_channels_", "USB") self.speak_dialog("BlindsAdjust") if "volume" in msg.data.get('utterance'): self.send_post_openhab("RXV685Main_Zone_Zone_channels_Volume", number) self.speak_dialog("BlindsAdjust") if "scene" in msg.data.get('utterance'): self.send_post_openhab("RXV685Main_Zone_Zone_channels_Scene", "Scene "+number) self.speak_dialog("BlindsAdjust")
def things_controlG(self,msg): utterance = msg.data["utterance"] number = str(extract_number(utterance)) if "licht" in msg.data.get('utterance') or "lichter" in msg.data.get('utterance') or "beleuchtung" in msg.data.get('utterance'): if "grün" in msg.data.get('utterance'): if "küche" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Color", "120,100,100") self.speak_dialog("BlindsAdjustG") if "wohnzimmer" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Color", "120,100,100") self.speak_dialog("BlindsAdjustG") elif "raum" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Color", "120,100,100") self.speak_dialog("BlindsAdjustG") if "rot" in msg.data.get('utterance'): if "küche" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Color", "0,100,100") self.speak_dialog("BlindsAdjustG") if "wohnzimmer" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Color", "0,100,100") self.speak_dialog("BlindsAdjustG") elif "raum" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Color", "0,100,100") self.speak_dialog("BlindsAdjustG") if "blau" in msg.data.get('utterance'): if "küche" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Color", "202,100,100") self.speak_dialog("BlindsAdjustG") if "wohnzimmer" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Color", "202,100,100") self.speak_dialog("BlindsAdjustG") elif "raum" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Color", "202,100,100") self.speak_dialog("BlindsAdjustG") if "gelb" in msg.data.get('utterance'): if "küche" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Color", "46,99,100") self.speak_dialog("BlindsAdjustG") if "wohnzimmer" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Color", "46,99,100") self.speak_dialog("BlindsAdjustG") elif "raum" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Color", "46,99,100") self.speak_dialog("BlindsAdjustG") if "orange" in msg.data.get('utterance'): if "küche" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Color", "27,100,100") self.speak_dialog("BlindsAdjustG") if "wohnzimmer" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Color", "27,100,100") self.speak_dialog("BlindsAdjustG") elif "raum" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Color", "27,100,100") self.speak_dialog("BlindsAdjustG") if "pink" in msg.data.get('utterance') or "rosa" in msg.data.get('utterance'): if "küche" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Color", "326,100,100") self.speak_dialog("BlindsAdjustG") if "wohnzimmer" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Color", "326,100,100") self.speak_dialog("BlindsAdjustG") elif "raum" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Color", "326,100,100") self.speak_dialog("BlindsAdjustG") if "violett" in msg.data.get('utterance') or "lila" in msg.data.get('utterance'): if "küche" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Color", "263,78,100") self.speak_dialog("BlindsAdjustG") if "wohnzimmer" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Color", "263,78,100") self.speak_dialog("BlindsAdjustG") elif "raum" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Color", "263,78,100") self.speak_dialog("BlindsAdjustG") if "weiß" in msg.data.get('utterance'): if "küche" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Color", "191,1,100") self.speak_dialog("BlindsAdjustG") if "wohnzimmer" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Color", "191,1,100") self.speak_dialog("BlindsAdjustG") elif "raum" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Color", "191,1,100") self.speak_dialog("BlindsAdjustG") else: #si el número es distinto de null if "küche" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp1_Color_Dimmer", number) self.speak_dialog("BlindsAdjustG") if "wohnzimmer" in msg.data.get('utterance'): self.send_post_openhab("HueBulb_Color_Dimmer", number) self.speak_dialog("BlindsAdjustG") elif "raum" in msg.data.get('utterance') or "bedroom" in msg.data.get('utterance'): self.send_post_openhab("HueColorLamp2_Color_Dimmer", number) self.speak_dialog("BlindsAdjustG") if "jalousie" in msg.data.get('utterance') or "rollo" in msg.data.get('utterance') or "blende" in msg.data.get('utterance') or "vorhang" in msg.data.get('utterance'): if "küche" in msg.data.get('utterance'): if "hochziehen" in msg.data.get('utterance') or "hochfahren" in msg.data.get('utterance') : self.send_post_openhab("Kuche_Jalousie1", "0") self.send_post_openhab("Kuche_Jalousie2", "0") self.speak_dialog("BlindsUpG") if "herunterziehen" in msg.data.get('utterance'): self.send_post_openhab("Kuche_Jalousie1", "100") self.send_post_openhab("Kuche_Jalousie2", "100") self.speak_dialog("BlindsDownG") elif "auf" in msg.data.get('utterance'): self.send_post_openhab("Kuche_Jalousie1", number) self.send_post_openhab("Kuche_Jalousie2", number) self.speak_dialog("BlindsAdjustG") if "wohnzimmer" in msg.data.get('utterance'): if "hochziehen" in msg.data.get('utterance') or "hochfahren" in msg.data.get('utterance') : self.send_post_openhab("WZ_Jalousien", "0") self.speak_dialog("BlindsUpG") if "herunterziehen" in msg.data.get('utterance'): self.send_post_openhab("WZ_Jalousien", "100") self.speak_dialog("BlindsDownG") elif "auf" in msg.data.get('utterance'): self.send_post_openhab("WZ_Jalousien", number) self.speak_dialog("BlindsAdjustG") if "alle" in msg.data.get('utterance'): if "hochziehen" in msg.data.get('utterance') or "hochfahren" in msg.data.get('utterance') : self.send_post_openhab("Wohnung_Jalousien", "0") self.speak_dialog("BlindsUpG") if "herunterziehen" in msg.data.get('utterance'): self.send_post_openhab("Wohnung_Jalousien", "100") self.speak_dialog("BlindsDownG") elif "auf" in msg.data.get('utterance'): self.send_post_openhab("Wohnung_Jalousien", number) self.speak_dialog("BlindsAdjustG") if "musik" in msg.data.get('utterance') or "Stereoanlage" in msg.data.get('utterance') or "yamaha" in msg.data.get('utterance')or "soundsystem" in msg.data.get('utterance'): if "quelle" in msg.data.get('utterance') or "funktion" in msg.data.get('utterance'): if "bluetooth" in msg.data.get('utterance'): self.send_post_openhab("RXV685Main_Zone_Zone_channels_", "Bluetooth") self.speak_dialog("BlindsAdjustG") if "tuner" in msg.data.get('utterance') or "radio" in msg.data.get('utterance'): self.send_post_openhab("RXV685Main_Zone_Zone_channels_", "Tuner") self.speak_dialog("BlindsAdjustG") if "auxiliar" in msg.data.get('utterance') or "aux" in msg.data.get('utterance') or "hilfsfunktion" in msg.data.get('utterance'): self.send_post_openhab("RXV685Main_Zone_Zone_channels_", "aux") self.speak_dialog("BlindsAdjustG") if "net radio" in msg.data.get('utterance'): self.send_post_openhab("RXV685Main_Zone_Zone_channels_", "NET RADIO") self.speak_dialog("BlindsAdjustG") if "volume" in msg.data.get('utterance') or "lautstärke " in msg.data.get('utterance') or "umfang " in msg.data.get('utterance'): self.send_post_openhab("RXV685Main_Zone_Zone_channels_Volume", number) self.speak_dialog("BlindsAdjustG") if "szene" in msg.data.get('utterance'): self.send_post_openhab("RXV685Main_Zone_Zone_channels_Scene", "Scene "+number) self.speak_dialog("BlindsAdjustG")
def createEventt(self): storage1 = Storage('info3.dat') credentials = storage1.get() if credentials is None or credentials.invalid == True: credentials = tools.run_flow(FLOW, storage1) print(credentials) # Create an httplib2.Http object to handle our HTTP requests and # authorize it with our good Credentials. http = httplib2.Http() http = credentials.authorize(http) service = build('calendar', 'v3', http=http) people_service = build(serviceName='people', version='v1', http=http) print("authorized") # To get a list of people in the user's contacts, results = people_service.people().connections().list( resourceName='people/me', pageSize=100, personFields='names,emailAddresses', fields='connections,totalItems,nextSyncToken').execute() connections = results.get('connections', []) #need to verify this #self.speak(connections) #get informations about the event tittle = self.get_response("what is the name of the event") description = self.get_response("can you describe more the event") strtdate = self.get_response("when the event starts") st = extract_datetime(strtdate) enddate = self.get_response("when the event ends") et = extract_datetime(enddate) st = st[0] - self.utc_offset et = et[0] - self.utc_offset datestart = st.strftime('%Y-%m-%dT%H:%M:00') datend = et.strftime('%Y-%m-%dT%H:%M:00') datend += UTC_TZ datestart += UTC_TZ # getting contacts emails and names in two lists nameliste and adsmails nameListe = [] adsmails = [] # attendee est la liste des invités qui sont disponibles attendee = [] for person in connections: emails = person.get('emailAddresses', []) names = person.get('names', []) adsmails.append(emails[0].get('value')) nameListe.append(names[0].get('displayName')) # liste des emails de toutes les salles de focus freemails = [] freerooms = [] nameroom = [ "Midoune Meeting Room", "Aiguilles Meeting Room", "Barrouta Meeting Room", "Kantaoui Meeting Room", "Gorges Meeting Room", "Ichkeul Meeting Room", "Khemir Meeting Room", "Tamaghza Meeting Room", "Friguia Meeting Room", "Ksour Meeting Room", "Medeina Meeting Room", "Thyna Meeting Room" ] emailroom = [ "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" ] for i in range(0, len(emailroom)): body = { "timeMin": datestart, "timeMax": datend, "timeZone": 'America/Los_Angeles', "items": [{ "id": emailroom[i] }] } roomResult = service.freebusy().query(body=body).execute() room_dict = roomResult[u'calendars'] for cal_room in room_dict: print(cal_room, ':', room_dict[cal_room]) case = room_dict[cal_room] for j in case: if (j == 'busy' and case[j] == []): # la liste freerooms va prendre les noms des salles free freerooms.append(nameroom[i]) freemails.append(emailroom[i]) suggroom = freerooms[0] suggmail = freemails[0] reservation = self.get_response( 'do you need to make a reservation for a meeting room? Yes or No?') if reservation == 'yes': self.speak_dialog("suggestionroom", data={"suggroom": suggroom}) x = self.get_response( "Do you agree making a reservation for this meeting room") if x == "yes": room = suggroom attendee.append(suggmail) else: s = ",".join(freerooms) # print("les salles disponibles a cette date sont", freerooms) self.speak_dialog("freerooms", data={"s": s}) room = self.get_response( 'which Room do you want to make a reservation for??') for i in range(0, len(freerooms)): if (freerooms[i] == room): # ajouter l'email de room dans la liste des attendees attendee.append(freemails[i]) else: room = '' #adding attendees #verify if the attendee in the connection liste and if he is free confirm = self.get_response( "Do you want to invite someone? yes or no?") if confirm == 'yes': n_attendee = self.get_response( " how many persons would you like to invite") n = extract_number(n_attendee) nb = n print(n) j = 0 while j < n: exist = False x = self.get_response("who do you want to invite") for l in range(0, len(nameListe)): if x == nameListe[l]: self.speak_dialog("exist") exist = True mail = adsmails[l] #attendee.append(mail) # on va verifier la disponibilité de chaque invité #methode avec freebusy body = { "timeMin": datestart, "timeMax": datend, "timeZone": 'America/Los_Angeles', "items": [{ "id": mail }] } eventsResult = service.freebusy().query( body=body).execute() cal_dict = eventsResult[u'calendars'] print(cal_dict) for cal_name in cal_dict: print(cal_name, ':', cal_dict[cal_name]) statut = cal_dict[cal_name] for i in statut: if (i == 'busy' and statut[i] == []): self.speak_dialog("free", data={"att": x}) attendee.append(mail) #ajouter l'email de x ala liste des attendee elif (i == 'busy' and statut[i] != []): self.speak_dialog("busy", data={"att": x}) nb -= 1 if exist == False: self.speak_dialog("notexist") j += 1 attendeess = [] for i in range(len(attendee)): email = {'email': attendee[i]} attendeess.append(email) notification = self.get_response( 'would you like to send notification to attendees?') if notification == 'yes': notif = True, else: notif = False #creation d'un evenement event = { 'summary': tittle, 'location': room, 'description': description, 'start': { 'dateTime': datestart, 'timeZone': 'America/Los_Angeles', }, 'end': { 'dateTime': datend, 'timeZone': 'America/Los_Angeles', }, 'recurrence': ['RRULE:FREQ=DAILY;COUNT=1'], 'attendees': attendeess, 'reminders': { 'useDefault': False, 'overrides': [ { 'method': 'email', 'minutes': 24 * 60 }, { 'method': 'popup', 'minutes': 10 }, ], }, } if nb == 0: self.speak_dialog("cancellEvent") elif nb == n: event = service.events().insert(calendarId='primary', sendNotifications=notif, body=event).execute() print('Event created: %s' % (event.get('htmlLink'))) self.speak_dialog("eventCreated") else: res = self.get_response( 'Some of the attendees are busy would you like to continue creating the event yes or no?' ) if res == 'yes': event = service.events().insert(calendarId='primary', sendNotifications=notif, body=event).execute() print('Event created: %s' % (event.get('htmlLink'))) self.speak_dialog("eventCreated") elif res == 'no': self.speak_dialog("eventCancelled")
def handle_switch_to_pos(self, message): pos = message.data.get('pos_nr') pos = extract_number(pos) pos = str(int(pos)) self.send_channel_pos(pos)