def createNewEvent(self, eventName, startingTimeTuple, endingTimeTuple): # Creates a new event and returns its identifier. eventObject = Event() eventObject.timeZoneId=self.assistant.timeZoneId eventObject.title=eventName eventObject.startDate=startingTimeTuple eventObject.endDate=endingTimeTuple creatorObject = DomainObjectCreate(self.refId) creatorObject.object = eventObject createCompleted = self.getResponseForRequest(creatorObject) return createCompleted['properties']['identifier']
def createReminder(self, speech, language): content_raw = re.match(".*reminder ([a-zA-Z0-9, ]+)$", speech, re.IGNORECASE) if content_raw == None: view_initial = AddViews(self.refId, dialogPhase="Reflection") view_initial.views = [AssistantUtteranceView(text=reminders.localizations['reminderDefaults']['nothing'][language], speakableText=reminders.localizations['reminderDefaults']['nothing'][language], dialogIdentifier="Reminder#failed")] self.sendRequestWithoutAnswer(view_initial) else: view_initial = AddViews(self.refId, dialogPhase="Reflection") view_initial.views = [AssistantUtteranceView(text=reminders.localizations['reminderDefaults']['searching'][language], speakableText=reminders.localizations['reminderDefaults']['searching'][language], dialogIdentifier="Reminder#creating")] self.sendRequestWithoutAnswer(view_initial) content_raw = content_raw.group(1).strip() if "me to" in content_raw: split = content_raw.split(' ') if split[0] == "me to": split.pop(0) content_raw = ' '.join(map(str, split)) if "for" in content_raw: split = content_raw.split(' ') if split[0] == "for": split.pop(0) content_raw = ' '.join(map(str, split)) # adds reminder reminder_create = Create() reminder_create.subject = content_raw domain_object = DomainObjectCreate(refId = self.refId) domain_object.object = reminder_create reminder_return = self.getResponseForRequest(domain_object) print reminder_return # retrieves reminder # update / commit reminder reminder_update = Update() reminder_update.identifier = reminder_return["properties"]["identifier"] domain_object_up = DomainObjectCommit(refId = self.refId) domain_object_up.identifier = reminder_update reminder_update_return = self.getResponseForRequest(domain_object_up) print reminder_update_return # send view view = AddViews(self.refId, dialogPhase="Summary") view1 = AssistantUtteranceView(text=reminders.localizations['reminderDefaults']['result'][language], speakableText=reminders.localizations['reminderDefaults']['result'][language], dialogIdentifier="Reminder#created") reminder_ = ReminderObject() reminder_.subject = content_raw reminder_.identifier = reminder_return["properties"]["identifier"] view2 = ReminderSnippet(reminders=[reminder_]) view.views = [view1, view2] self.sendRequestWithoutAnswer(view) self.complete_request()
def createReminder(self, speech, language, regMatched): content_raw = regMatched.group('content').strip(); if content_raw == None or content_raw == '': content_raw = self.ask(reminders.localizations['reminderDefaults']['nothing'][language]) print content_raw view_initial = AddViews(self.refId, dialogPhase="Reflection") view_initial.views = [AssistantUtteranceView(text=reminders.localizations['reminderDefaults']['searching'][language], speakableText=reminders.localizations['reminderDefaults']['searching'][language], dialogIdentifier="Reminder#creating")] self.sendRequestWithoutAnswer(view_initial) # adds reminder reminder_create = Create() reminder_create.subject = content_raw domain_object = DomainObjectCreate(refId = self.refId) domain_object.object = reminder_create reminder_return = self.getResponseForRequest(domain_object) print reminder_return # retrieves reminder # update / commit reminder reminder_update = Update() reminder_update.identifier = reminder_return["properties"]["identifier"] domain_object_up = DomainObjectCommit(refId = self.refId) domain_object_up.identifier = reminder_update reminder_update_return = self.getResponseForRequest(domain_object_up) print reminder_update_return # send view view = AddViews(self.refId, dialogPhase="Summary") view1 = AssistantUtteranceView(text=reminders.localizations['reminderDefaults']['result'][language], speakableText=reminders.localizations['reminderDefaults']['result'][language], dialogIdentifier="Reminder#created") reminder_ = ReminderObject() reminder_.subject = content_raw reminder_.identifier = reminder_return["properties"]["identifier"] view2 = ReminderSnippet(reminders=[reminder_]) view.views = [view1, view2] self.sendRequestWithoutAnswer(view) self.complete_request()