当前位置: 首页>>代码示例>>Python>>正文


Python AddViews.views方法代码示例

本文整理汇总了Python中siriObjects.uiObjects.AddViews.views方法的典型用法代码示例。如果您正苦于以下问题:Python AddViews.views方法的具体用法?Python AddViews.views怎么用?Python AddViews.views使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在siriObjects.uiObjects.AddViews的用法示例。


在下文中一共展示了AddViews.views方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: currentTime

# 需要导入模块: from siriObjects.uiObjects import AddViews [as 别名]
# 或者: from siriObjects.uiObjects.AddViews import views [as 别名]
    def currentTime(self, speech, language):
        # first tell that we look it up
        view = AddViews(self.refId, dialogPhase="Reflection")
        view.views = [
            AssistantUtteranceView(
                text=timePlugin.localizations["currentTime"]["search"][language],
                speakableText=timePlugin.localizations["currentTime"]["search"][language],
                dialogIdentifier="Clock#getTime",
            )
        ]
        self.sendRequestWithoutAnswer(view)

        # tell him to show the current time
        view = AddViews(self.refId, dialogPhase="Summary")
        view1 = AssistantUtteranceView(
            text=timePlugin.localizations["currentTime"]["currentTime"][language],
            speakableText=timePlugin.localizations["currentTime"]["currentTime"][language],
            dialogIdentifier="Clock#showTimeInCurrentLocation",
        )
        clock = ClockObject()
        clock.timezoneId = self.connection.assistant.timeZoneId
        view2 = ClockSnippet(clocks=[clock])
        view.views = [view1, view2]
        self.sendRequestWithoutAnswer(view)
        self.complete_request()
开发者ID:413x,项目名称:SiriServer,代码行数:27,代码来源:timePlugin.py

示例2: resumeTimer

# 需要导入模块: from siriObjects.uiObjects import AddViews [as 别名]
# 或者: from siriObjects.uiObjects.AddViews import views [as 别名]
    def resumeTimer(self, speech, language):
        response = self.getResponseForRequest(TimerGet(self.refId))
        timer_properties = response["properties"]["timer"]["properties"]
        timer = TimerObject(timerValue=timer_properties["timerValue"], state=timer_properties["state"])

        if timer.state == "Paused":
            response = self.getResponseForRequest(TimerResume(self.refId))
            if response["class"] == "ResumeCompleted":
                view = AddViews(self.refId, dialogPhase="Completion")
                view1 = AssistantUtteranceView(
                    speakableText=timerPlugin.localizations["Timer"]["timerWasResumed"][language],
                    dialogIdentifier="Timer#timerWasResumed",
                )
                view2 = TimerSnippet(timers=[timer])
                view.views = [view1, view2]
                self.sendRequestWithoutAnswer(view)
            self.complete_request()
        else:
            view = AddViews(self.refId, dialogPhase="Completion")
            view1 = AssistantUtteranceView(
                speakableText=timerPlugin.localizations["Timer"]["timerIsAlreadyStopped"][language],
                dialogIdentifier="Timer#timerIsAlreadyStopped",
            )
            view2 = TimerSnippet(timers=[timer])
            view.views = [view1, view2]

            self.sendRequestWithoutAnswer(view)
            self.complete_request()
开发者ID:michael9559,项目名称:SiriServerPlugins,代码行数:30,代码来源:__init__.py

示例3: authtest

# 需要导入模块: from siriObjects.uiObjects import AddViews [as 别名]
# 或者: from siriObjects.uiObjects.AddViews import views [as 别名]
	def authtest(self, speech, language, regex):
		if self.assistant_id() == "[6CF4E775-2DB0-4C99-A5D8-DB1B35EEDE00":
			self.say("Zugelassen!")
		else:
			self.say("Netter Versuch, Newfag...","Netter Versuch Newfag.")
			ans = self.ask(u"  ▲\n▲ ▲","Ich wette, Du schaffst es nicht").lower()
			if ans != "op ist eine Schwuchtel" and ans != "new fag" and ans != "newfag":
				view = AddViews(self.refId, dialogPhase="Completion")
				ImageAnswer = AnswerObject(title=str("Trolololololololololololololololololololololololololololol"),lines=[AnswerObjectLine(image="http://harryj.co.uk/t.gif")])
				view1 = AnswerSnippet(answers=[ImageAnswer])
				view.views = [view1]
				self.sendRequestWithoutAnswer(view)
				answer = None
				filename = "./plugins/priv/cat.txt"
				file = open(filename, 'r')
				file_size = os.stat(filename)[6]
				while answer != "Yes" and answer != "Yeah":
					lnum = random.randint(0, file_size-1)
					file.seek((file.tell()+lnum)%file_size)
					file.readline()
					line=file.readline()
					self.say("Cat fact number "+str(lnum)+":\n"+str(line).rstrip('\n'))
					answer = self.ask("Did you know that?")
			view = AddViews(self.refId, dialogPhase="Completion")
			ImageAnswer = AnswerObject(title=str(""),lines=[AnswerObjectLine(image="http://harryj.co.uk/b.gif")])
			view1 = AnswerSnippet(answers=[ImageAnswer])
			view.views = [view1]
			self.sendRequestWithoutAnswer(view)
		self.complete_request()
开发者ID:sullenlook,项目名称:fragmichwas,代码行数:31,代码来源:__init__.py

示例4: pauseTimer

# 需要导入模块: from siriObjects.uiObjects import AddViews [as 别名]
# 或者: from siriObjects.uiObjects.AddViews import views [as 别名]
    def pauseTimer(self, speech, language):
        response = self.getResponseForRequest(TimerGet(self.refId))
        timer_properties = response['properties']['timer']['properties']
        timer = TimerObject(timerValue = timer_properties['timerValue'], state = timer_properties['state'])

        if timer.state == "Running":
            response = self.getResponseForRequest(TimerPause(self.refId))
            if response['class'] == "PauseCompleted":
                view = AddViews(self.refId, dialogPhase="Completion")
                view.views = [AssistantUtteranceView(speakableText=timerPlugin.localizations['Timer']['timerWasPaused'][language], dialogIdentifier="Timer#timerWasPaused")]
                self.sendRequestWithoutAnswer(view)
            self.complete_request()
        elif timer.state == "Paused":
            view = AddViews(self.refId, dialogPhase="Completion")
            view1 = AssistantUtteranceView(speakableText=timerPlugin.localizations['Timer']['timerIsAlreadyPaused'][language], dialogIdentifier="Timer#timerIsAlreadyPaused")
            view2 = TimerSnippet(timers=[timer])
            view.views = [view1, view2]

            self.sendRequestWithoutAnswer(view)
            self.complete_request()
        else:
            view = AddViews(self.refId, dialogPhase="Completion")
            view1 = AssistantUtteranceView(speakableText=timerPlugin.localizations['Timer']['timerIsAlreadyStopped'][language], dialogIdentifier="Timer#timerIsAlreadyStopped")
            view2 = TimerSnippet(timers=[timer])
            view.views = [view1, view2]

            self.sendRequestWithoutAnswer(view)
            self.complete_request()
开发者ID:apexad,项目名称:SiriServer,代码行数:30,代码来源:timerPlugin.py

示例5: writeNote

# 需要导入模块: from siriObjects.uiObjects import AddViews [as 别名]
# 或者: from siriObjects.uiObjects.AddViews import views [as 别名]
    def writeNote(self, speech, language):
        content_raw = re.findall(ur".*備忘錄(.*)",speech)[0]
        if content_raw == None or content_raw == '':
            content_raw = self.ask(u"請問要記錄什麼?")

            view_initial = AddViews(self.refId, dialogPhase="Reflection")
            view_initial.views = [AssistantUtteranceView(text=note.localizations['noteDefaults']['searching'][language], speakableText=note.localizations['noteDefaults']['searching'][language], dialogIdentifier="Note#creating")]
            self.sendRequestWithoutAnswer(view_initial)

            note_create = Create()
            note_create.contents = content_raw
            note_return = self.getResponseForRequest(note_create)

            view = AddViews(self.refId, dialogPhase="Summary")
            view1 = AssistantUtteranceView(text=note.localizations['noteDefaults']['result'][language], speakableText=note.localizations['noteDefaults']['result'][language], dialogIdentifier="Note#created")

            note_ = NoteObject()
            note_.contents = content_raw
            note_.identifier = note_return["properties"]["identifier"]

            view2 = NoteSnippet(notes=[note_])
            view.views = [view1, view2]
            self.sendRequestWithoutAnswer(view)
        else:
            view_initial = AddViews(self.refId, dialogPhase="Reflection")
            view_initial.views = [AssistantUtteranceView(text=note.localizations['noteDefaults']['searching'][language], speakableText=note.localizations['noteDefaults']['searching'][language], dialogIdentifier="Note#creating")]
            self.sendRequestWithoutAnswer(view_initial)
            
            content_raw = re.findall(ur".*備忘錄(.*)",speech)[0]
            if "saying" in content_raw:
                split = content_raw.split(' ')
                if split[0] == "saying":
                    split.pop(0)
                    content_raw = ' '.join(map(str, split))
            if "that" in content_raw:
                split = content_raw.split(' ')
                if split[0] == "that":
                    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))
                
            note_create = Create()
            note_create.contents = content_raw
            note_return = self.getResponseForRequest(note_create)
        
            view = AddViews(self.refId, dialogPhase="Summary")
            view1 = AssistantUtteranceView(text=note.localizations['noteDefaults']['result'][language], speakableText=note.localizations['noteDefaults']['result'][language], dialogIdentifier="Note#created")
        
            note_ = NoteObject()
            note_.contents = content_raw
            note_.identifier = note_return["properties"]["identifier"]
        
            view2 = NoteSnippet(notes=[note_])
            view.views = [view1, view2]
            self.sendRequestWithoutAnswer(view)
        self.complete_request()
开发者ID:hirakujira,项目名称:ChineseSiriServer,代码行数:62,代码来源:notes.py

示例6: writeNote

# 需要导入模块: from siriObjects.uiObjects import AddViews [as 别名]
# 或者: from siriObjects.uiObjects.AddViews import views [as 别名]
 def writeNote(self, speech, language):
     content_raw = re.match(".*anote ([a-zA-Z0-9, ]+)$", speech, re.IGNORECASE)
     if content_raw == None:
         view_initial = AddViews(self.refId, dialogPhase="Reflection")
         view_initial.views = [AssistantUtteranceView(text=note.localizations['noteDefaults']['nothing']["pt-BR"], speakableText=note.localizations['noteDefaults']['nothing']["pt-BR"], dialogIdentifier="Note#failed")]
         self.sendRequestWithoutAnswer(view_initial)
     else:
         view_initial = AddViews(self.refId, dialogPhase="Reflection")
         view_initial.views = [AssistantUtteranceView(text=note.localizations['noteDefaults']['searching']["pt-BR"], speakableText=note.localizations['noteDefaults']['searching']["pt-BR"], dialogIdentifier="Note#creating")]
         self.sendRequestWithoutAnswer(view_initial)
         
         content_raw = content_raw.group(1).strip()
         if "que" in content_raw:
             split = content_raw.split(' ')
             if split[0] == "que":
                 split.pop(0)
                 content_raw = ' '.join(map(str, split))
             
         note_create = Create()
         note_create.contents = content_raw
         note_return = self.getResponseForRequest(note_create)
     
         view = AddViews(self.refId, dialogPhase="Summary")
         view1 = AssistantUtteranceView(text=note.localizations['noteDefaults']['result']["pt-BR"], speakableText=note.localizations['noteDefaults']['result']["pt-BR"], dialogIdentifier="Note#created")
     
         note_ = NoteObject()
         note_.contents = content_raw
         note_.identifier = note_return["properties"]["identifier"]
     
         view2 = NoteSnippet(notes=[note_])
         view.views = [view1, view2]
         self.sendRequestWithoutAnswer(view)
     self.complete_request()
开发者ID:edsonaj,项目名称:SiriServer,代码行数:35,代码来源:Anotacoes.py

示例7: setAlarm

# 需要导入模块: from siriObjects.uiObjects import AddViews [as 别名]
# 或者: from siriObjects.uiObjects.AddViews import views [as 别名]
    def setAlarm(self, speech, language):
        alarmString = re.match(alarmPlugin.res["setAlarm"][language], speech, re.IGNORECASE)

        alarmHour = int(alarmString.group("t1"))
        alarm24Hour = alarmHour
        alarmMinutes = alarmString.group("t2")
        alarmAMPM = alarmString.group("am")
        alarmLabelExists = alarmString.group("name")

        # check if we are naming the alarm
        if alarmLabelExists == None:
            alarmLabel = None
        else:
            alarmLabel = alarmString.group(5)

        # the siri alarm object requires 24 hour clock
        if alarmAMPM == "pm" and alarmHour != 12:
            alarm24Hour += 12

        if alarmMinutes == None:
            alarmMinutes = "00"
        else:
            alarmMinutes = int(alarmMinutes.strip())

        view = AddViews(self.refId, dialogPhase="Reflection")
        view.views = [
            AssistantUtteranceView(
                speakableText=alarmPlugin.localizations["Alarm"]["settingAlarm"][language],
                dialogIdentifier="Alarm#settingAlarm",
            )
        ]
        self.sendRequestWithoutAnswer(view)

        # create the alarm
        alarm = AlarmObject(alarmLabel, int(alarmMinutes), alarm24Hour, None, 1)
        response = self.getResponseForRequest(AlarmCreate(self.refId, alarm))

        print(alarmPlugin.localizations["Alarm"]["alarmWasSet"][language].format(alarmHour, alarmMinutes, alarmAMPM))
        view = AddViews(self.refId, dialogPhase="Completion")

        if alarmLabel == None:
            view1 = AssistantUtteranceView(
                speakableText=alarmPlugin.localizations["Alarm"]["alarmWasSet"][language].format(
                    alarmHour, alarmMinutes, alarmAMPM
                ),
                dialogIdentifier="Alarm#alarmWasSet",
            )
        else:
            view1 = AssistantUtteranceView(
                speakableText=alarmPlugin.localizations["Alarm"]["alarmSetWithLabel"][language].format(
                    alarmLabelExists, alarmLabel, alarmHour, alarmMinutes, alarmAMPM
                ),
                dialogIdentifier="Alarm#alarmSetWithLabel",
            )

        view2 = AlarmSnippet(alarms=[alarm])
        view.views = [view1, view2]
        self.sendRequestWithoutAnswer(view)
        self.complete_request()
开发者ID:castvoid,项目名称:SiriServerCore,代码行数:61,代码来源:__init__.py

示例8: googleplaces_search

# 需要导入模块: from siriObjects.uiObjects import AddViews [as 别名]
# 或者: from siriObjects.uiObjects.AddViews import views [as 别名]
 def googleplaces_search(self, speech, language, regex):
      if language == "zh-CN":
          self.say(u'正在检索...', ' ')
      else:
          self.say('Searching...',' ')
      mapGetLocation = self.getCurrentLocation()
      latitude= mapGetLocation.latitude
      longitude= mapGetLocation.longitude
      Title = regex.group(regex.lastindex).strip()
      Query = urllib.quote_plus(str(Title.encode("utf-8")))
      random_results = random.randint(2,15)
      googleurl = "https://maps.googleapis.com/maps/api/place/search/json?location={0},{1}&radius=5000&name={2}&sensor=true&key={3}".format(latitude,longitude,str(Query),str(googleplaces_api_key))
      try:
           jsonString = urllib2.urlopen(googleurl, timeout=20).read()
      except:
           jsonString = None
      if jsonString != None:
           response = json.loads(jsonString)
           if (response['status'] == 'OK') and (len(response['results'])):
                googleplaces_results = []
                for result in response['results']:
                     if "rating" in result:
                          avg_rating = result["rating"]
                     else:
                          avg_rating = 0.0
                     rating = Rating(value=avg_rating, providerId='Google Places', count=0)
                     details = Business(totalNumberOfReviews=0,name=result['name'],rating=rating)
                     if (len(googleplaces_results) < random_results):
                          try:
                              mapitem = MapItem(label=result['name'], street=result['vicinity'], latitude=result['geometry']['location']['lat'], longitude=result['geometry']['location']['lng'])
                              mapitem.detail = details
                              googleplaces_results.append(mapitem)
                          except:
                              pass
                     else:
                          break
                mapsnippet = MapItemSnippet(items=googleplaces_results)
                count_min = min(len(response['results']),random_results)
                count_max = max(len(response['results']),random_results)
                view = AddViews(self.refId, dialogPhase="Completion")
                if language == "zh-CN":
                    view.views = [AssistantUtteranceView(speakableText=u'我找到'+str(count_max)+u'个有关'+Title+u'的结果。其中有'+str(count_min)+u'个离您很近:', dialogIdentifier="googlePlacesMap"), mapsnippet]
                else:
                    view.views = [AssistantUtteranceView(speakableText='I found '+str(count_max)+' '+str(Title)+' results... '+str(count_min)+' of them are fairly close to you:', dialogIdentifier="googlePlacesMap"), mapsnippet]
                self.sendRequestWithoutAnswer(view)
           else:
                if language == "zh-CN":
                    self.say(u"抱歉,我找不到您附近有关"+Title+u"的地点。")
                else:
                    self.say("I'm sorry but I did not find any results for "+str(Title)+" near you!")
      else:
          if language == "zh-CN":
              self.say(u"抱歉,我找不到您附近有关"+Title+u"的地点。")
          else:
              self.say("I'm sorry but I did not find any results for "+str(Title)+" near you!")
      self.complete_request()
开发者ID:linusyang,项目名称:SiriServerCore,代码行数:58,代码来源:__init__.py

示例9: setTimer

# 需要导入模块: from siriObjects.uiObjects import AddViews [as 别名]
# 或者: from siriObjects.uiObjects.AddViews import views [as 别名]
    def setTimer(self, speech, language):
        m = re.match(timer.res['setTimer'][language], speech, re.IGNORECASE)
        timer_length = ' '.join(m.group(1, 2))
        duration = parse_timer_length(timer_length, language)

        view = AddViews(self.refId, dialogPhase="Reflection")
        view.views = [
            AssistantUtteranceView(
                speakableText=timer.localizations['Timer']['settingTimer'][language],
                dialogIdentifier="Timer#settingTimer")]
        self.sendRequestWithoutAnswer(view)

        # check the current state of the timer
        response = self.getResponseForRequest(TimerGet(self.refId))
        if response['class'] == 'CancelRequest':
            self.complete_request()
            return
        timer_properties = response['properties']['timer']['properties']
        timer = TimerObject(timerValue=timer_properties['timerValue'],
                state=timer_properties['state'])

        if timer.state == "Running":
            # timer is already running!
            view = AddViews(self.refId, dialogPhase="Completion")
            view1 = AssistantUtteranceView(speakableText=timer.localizations['Timer']['timerIsAlreadyRunning'][language], dialogIdentifier="Timer#timerIsAlreadyRunning")
            view2 = TimerSnippet(timers=[timer], confirm=True)
            view.views = [view1, view2]
            utterance = self.getResponseForRequest(view)
            #if response['class'] == 'StartRequest':
            view = AddViews(self.refId, dialogPhase="Reflection")
            view.views = [AssistantUtteranceView(speakableText=timer.localizations['Timer']['settingTimer'][language], dialogIdentifier="Timer#settingTimer")]
            self.sendRequestWithoutAnswer(view)

            if re.match('\^timerConfirmation\^=\^no\^', utterance):
                # user canceled
                view = AddViews(self.refId, dialogPhase="Completion")
                view.views = [AssistantUtteranceView(speakableText=timer.localizations['Timer']['wontSetTimer'][language], dialogIdentifier="Timer#wontSetTimer")]
                self.sendRequestWithoutAnswer(view)
                self.complete_request()
                return
            else:
                # user wants to set the timer still - continue on
                pass

        # start a new timer
        timer = TimerObject(timerValue = duration, state = "Running")
        response = self.getResponseForRequest(TimerSet(self.refId, timer=timer))
        
        print(timer.localizations['Timer']['timerWasSet'][language].format(timer_length))
        view = AddViews(self.refId, dialogPhase="Completion")
        view1 = AssistantUtteranceView(speakableText=timer.localizations['Timer']['timerWasSet'][language].format(timer_length), dialogIdentifier="Timer#timerWasSet")
        view2 = TimerSnippet(timers=[timer])
        view.views = [view1, view2]
        self.sendRequestWithoutAnswer(view)
        self.complete_request()
开发者ID:khw1006,项目名称:SiriServer,代码行数:57,代码来源:timerPlugin.py

示例10: createReminder

# 需要导入模块: from siriObjects.uiObjects import AddViews [as 别名]
# 或者: from siriObjects.uiObjects.AddViews import views [as 别名]
    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()
开发者ID:acenario,项目名称:i4SiriServer-Ripped-from-Eichhoernchen-,代码行数:55,代码来源:__init__.py

示例11: wakeup

# 需要导入模块: from siriObjects.uiObjects import AddViews [as 别名]
# 或者: from siriObjects.uiObjects.AddViews import views [as 别名]
    def wakeup(self, speech, language):
        alarmString = re.match(alarmPlugin.wake['wakeup'][language], speech, re.IGNORECASE)

        if language == 'fr-FR':
            labelGroupId = 8
            alarmHour = int(alarmString.group(4))
            alarm24Hour = alarmHour
            alarmMinutes = alarmString.group(6)
            alarmAMPM = ""
            alarmLabelExists = alarmString.group(labelGroupId)
        else:
            labelGroupId = 4
            alarmHour = int(alarmString.group(1))
            alarm24Hour = alarmHour
            alarmMinutes = alarmString.group(2)
            alarmAMPM = alarmString.group(3)
            alarmLabelExists = alarmString.group(labelGroupId)

        #check if we are naming the alarm
        if alarmLabelExists == None:
            alarmLabel = None
        else:
            alarmLabel = alarmString.group(labelGroupId)

        #the siri alarm object requires 24 hour clock
        if (alarmAMPM == "pm" and alarmHour != 12):
            alarm24Hour += 12
        if alarmMinutes == None:
            alarmMinutes = "00"
        else:
            alarmMinutes = int(alarmMinutes.strip())
        view = AddViews(self.refId, dialogPhase="Reflection")
        view.views = [
            AssistantUtteranceView(
                speakableText=alarmPlugin.localizations['Alarm']['settingAlarm'][language],
                dialogIdentifier="Alarm#settingAlarm")]
        self.sendRequestWithoutAnswer(view)

        #create the alarm
        alarm = AlarmObject(alarmLabel, int(alarmMinutes), alarm24Hour, None, 1)
        response = self.getResponseForRequest(AlarmCreate(self.refId, alarm))
        #print(alarmPlugin.localizations['Alarm']['alarmWasSet'][language].format(alarmHour, alarmMinutes, alarmAMPM))
        view = AddViews(self.refId, dialogPhase="Completion")
        if alarmLabel == None:
            view1 = AssistantUtteranceView(speakableText=alarmPlugin.localizations['Alarm']['alarmWasSet'][language].format(alarmHour, alarmMinutes, alarmAMPM), dialogIdentifier="Alarm#alarmWasSet")
        else:
            view1 = AssistantUtteranceView(speakableText=alarmPlugin.localizations['Alarm']['alarmSetWithLabel'][language].format(alarmLabelExists, alarmLabel, alarmHour, alarmMinutes, alarmAMPM), dialogIdentifier="Alarm#alarmSetWithLabel")
        view2 = AlarmSnippet(alarms=[alarm])
        view.views = [view1, view2]
        self.sendRequestWithoutAnswer(view)
        self.complete_request()
开发者ID:Doriginal,项目名称:SiriServer,代码行数:53,代码来源:alarmPlugin.py

示例12: moviecover

# 需要导入模块: from siriObjects.uiObjects import AddViews [as 别名]
# 或者: from siriObjects.uiObjects.AddViews import views [as 别名]
    def moviecover(self, speech, language, regex):

        query = regex.group(regex.lastindex).strip()
        search = self.res["search_cover"][language]
        self.say(search.format(query))
        infos = self.searchMovie(query, language)

        ImageURL = None
        if infos != None:
            try:
                here = self.res["here_cover"][language]
                self.say(here.format(infos["title"]))
                ImageURL = infos["cover url"]
            except:
                no = self.res["no_cover"][language]
                self.say(no.format(infos["title"]))

        if ImageURL != None:
            ImageUrlBig = imdb.helpers.fullSizeCoverURL(infos)
            if ImageUrlBig != None:
                ImageURL = ImageUrlBig
            view = AddViews(self.refId, dialogPhase="Completion")
            ImageAnswer = AnswerObject(title=infos["title"], lines=[AnswerObjectLine(image=ImageURL)])
            view1 = AnswerSnippet(answers=[ImageAnswer])
            view.views = [view1]
            self.sendRequestWithoutAnswer(view)

        self.complete_request()
开发者ID:bexel,项目名称:SiriServer,代码行数:30,代码来源:imdbPlugin.py

示例13: do_webrequest

# 需要导入模块: from siriObjects.uiObjects import AddViews [as 别名]
# 或者: from siriObjects.uiObjects.AddViews import views [as 别名]
    def do_webrequest(self, speech, language):
        
        # Edit this adress.
        pireLocation = 'http://dib.li/siri/response.php'
        
        location = self.getCurrentLocation(force_reload=True)
        postdata = {
        	'text': speech.replace("Test", "", 1),
        	'language': language,
        	'latitude': str( location.latitude ),
        	'longitude': str( location.longitude ),
        	'timezone': self.assistant.timeZoneId,
        	'region': self.assistant.region
        };
        
        req = urllib2.Request( pireLocation + "?" + urllib.urlencode( postdata ),
			headers = {
     		"Content-Type": "application/json",
			"Accept": "*/*",   
        	"User-Agent": "pire-plugin", 
       	})
       	
        webjson = urllib2.urlopen(req).read()
        request = json.loads(webjson)

        view = AddViews(self.refId, dialogPhase="Summary")
        view.views = request
        print view.to_plist()
        self.sendRequestWithoutAnswer(view.to_plist())
        self.complete_request()
开发者ID:Chr0meCoda,项目名称:Siri-Command-Manager,代码行数:32,代码来源:webservice.py

示例14: displaypicture

# 需要导入模块: from siriObjects.uiObjects import AddViews [as 别名]
# 或者: from siriObjects.uiObjects.AddViews import views [as 别名]
 def displaypicture(self, speech, language, regex):
     if language == "zh-CN":
         Title = regex.group(3).strip()
     else:
         Title = regex.group(regex.lastindex).strip()
     Query = urllib.quote_plus(Title.encode("utf-8"))
     SearchURL = u'https://ajax.googleapis.com/ajax/services/search/images?v=1.0&imgsz=small|medium|large|xlarge&q=' + str(Query)
     try:
         if language == "zh-CN":
             self.say(u"这是有关"+str(Title.encode("utf-8"))+"的图片:")
         else:
             self.say("Here is the image for "+Title+"...")
         jsonResponse = urllib2.urlopen(SearchURL).read()
         jsonDecoded = json.JSONDecoder().decode(jsonResponse)
         ImageURL = jsonDecoded['responseData']['results'][0]['unescapedUrl']
         view = AddViews(self.refId, dialogPhase="Completion")
         ImageAnswer = AnswerObject(title=Title,lines=[AnswerObjectLine(image=ImageURL)])
         view1 = AnswerSnippet(answers=[ImageAnswer])
         view.views = [view1]
         self.sendRequestWithoutAnswer(view)
         self.complete_request()
     except (urllib2.URLError):
         if language == "zh-CN":
             self.say(u"抱歉,我无法连接谷歌图片服务。")
         else:
             self.say("Sorry, a connection to Google Images could not be established.")
         self.complete_request()
开发者ID:jonesgithub,项目名称:SiriServer,代码行数:29,代码来源:displaypicture.py

示例15: quakesearch

# 需要导入模块: from siriObjects.uiObjects import AddViews [as 别名]
# 或者: from siriObjects.uiObjects.AddViews import views [as 别名]
 def quakesearch(self, speech, language, regex):
     searchString = regex.group(regex.lastindex).strip()
     gefunden = 0
     html = urllib.urlopen("http://www.emsc-csem.org/service/rss/rss.php?typ=emsc").read()
     dom = xml.dom.minidom.parseString(html)
     self.say("Überprüfung meiner Quellen...")
     for node in dom.getElementsByTagName("item"):
         sendtitle = node.getElementsByTagName("title")
         sendtime = node.getElementsByTagName("emsc:time")
         sendlat = node.getElementsByTagName("geo:lat")
         sendlong = node.getElementsByTagName("geo:long")
         sendmag = node.getElementsByTagName("emsc:magnitude")
         sendeinfo = sendtitle[0].firstChild.data + "\n" + sendtime[0].firstChild.data
         if re.match(".*" + searchString + ".*", sendeinfo, re.IGNORECASE):
             gefunden = 1
             # self.say(sendeinfo, (' '))
             view = AddViews(self.refId, dialogPhase="Completion")
             the_header = "Epicenter: " + sendtitle[0].firstChild.data
             Location = SiriLocation(
                 the_header, "", "", "", "", "", sendlat[0].firstChild.data, sendlong[0].firstChild.data
             )
             mapsnippet = SiriMapItemSnippet(items=[SiriMapItem(the_header, Location)])
             view.views = [AssistantUtteranceView(text=sendeinfo, dialogIdentifier="Map"), mapsnippet]
             self.sendRequestWithoutAnswer(view)
     if gefunden == 0:
         self.say(u'Sorry, ich fand keine Erdbeben fuer "' + searchString + '"')
     self.complete_request()
开发者ID:sullenlook,项目名称:plugins,代码行数:29,代码来源:__init__.py


注:本文中的siriObjects.uiObjects.AddViews.views方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。