SiriServerCore icon indicating copy to clipboard operation
SiriServerCore copied to clipboard

Trying to work on a "notes" plugin, but it does not work...

Open manuw2009 opened this issue 10 years ago • 0 comments

Hi, the following plugin used to work on IOS 5, but it's not working anymore with IOS6. It waits endlessly at some point below =>
note_return = self.getResponseForRequest(note_create) Could anyone please help ?

Thank you

!/usr/bin/python

-- coding: utf-8 --

import re import urllib2, urllib import json import logging from uuid import uuid4 from plugin import *

from siriObjects.baseObjects import AceObject, ClientBoundCommand from siriObjects.uiObjects import AddViews, AssistantUtteranceView from siriObjects.systemObjects import DomainObject

class NoteSnippet(AceObject): def init(self, notes=None): super(NoteSnippet, self).init("Snippet", "com.apple.ace.note") self.notes = notes if notes != None else []

def to_plist(self):
self.add_property('notes')
return super(NoteSnippet, self).to_plist()

class NoteObject(AceObject): def init(self, contents="", identifier=""): super(NoteObject, self).init("Object", "com.apple.ace.note") self.contents = contents self.identifier = identifier def to_plist(self): self.add_property('contents') self.add_property('identifier') return super(NoteObject, self).to_plist()

class Create(ClientBoundCommand): def init(self, refId=None, aceId=None, contents=""): super(Create, self).init("Create", "com.apple.ace.note", None, None) self.contents = contents self.aceId= aceId if aceId != None else str.upper(str(uuid4())) self.refId = refId if refId != None else str.upper(str(uuid4()))

def to_plist(self):
self.add_item('aceId')
self.add_item('refId')
self.add_property('contents')
return super(Create, self).to_plist()

class note(Plugin): localizations = {"noteDefaults": {"searching":{"en-US": "Creating your note ...","fr-FR": u"Création de votre note..."}, "result": {"en-US": "Here is your note:","fr-FR": "Voici votre note :"}, "nothing": {"en-US": "What should I note?","fr-FR": "Que dois-je noter ?"}}, "failure": { "en-US": "I cannot type your note right now.", "fr-FR": "Je ne peux pas écrire votre note maintenant." } } @register("en-US", "(._note [a-zA-Z0-9]+)|(._create._note [a-zA-Z0-9]+)|(._write._note [a-zA-Z0-9]+)") @register("fr-FR", u"(.créer? une note .)|(.note .)") def writeNote(self, speech, language): content_raw = re.match("._note (.*)$", speech, re.IGNORECASE) if content_raw == None: view_initial = AddViews(self.refId, dialogPhase="Reflection") view_initial.views = [AssistantUtteranceView(text=note.localizations['noteDefaults']['nothing'][language], speakableText=note.localizations['noteDefaults']['nothing'][language], dialogIdentifier="Note#failed")] self.sendRequestWithoutAnswer(view_initial) 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 = content_raw.group(1).strip()
    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 "que" in content_raw:
    split = content_raw.split(' ')
    if split[0] == "que":
        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
    #STUCK BELOW
        note_return = self.getResponseForRequest(note_create)
    self.say("après getresponse")
    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()

manuw2009 avatar Jul 16 '13 16:07 manuw2009