SiriServerCore
SiriServerCore copied to clipboard
SetAlertContext
Siri is sending packet SetAlertContext in which new messages and so on are stored. It is sent before starting the first SpeechRequest and it can't be requested again. So we need to save this plist/object and then provide function to get it from plugin. We must also add handler for ClearContext which will delete this plist/object.
I added this code :
to init of SiriProtocolHandler :
self.alertContext = None
to process_recognized_speech plugin = PluginManager.getPluginForImmediateExecution(self.assistant.assistantId, best_match, self.assistant.language, (self.send_object, self.send_plist, self.assistant, self.current_location), self.alertContext)
to end of received_plist :
elif ObjectIsCommand(plist, SetAlertContext):
self.logger.debug("Setting AlertContext")
self.alertContext = SetAlertContext(plist)
elif ObjectIsCommand(plist, SetAlertContext):
self.logger.debug("Clearing AlertContext")
self.alertContext = None
to plugin.py
def initialize(self, method, speech, language, send_object, send_plist, assistant, location, alertContext)
to initialize added self.alertContext = alertContext
to Plugin class added function def getContext(self): return self.alertContext
and in PluginManager edited getPluginForImmediateExecution as follows : def getPluginForImmediateExecution(assistantId, speech, language, otherPluginParams, alertContext): (sendObj, sendPlist, assistant, location) = otherPluginParams
(pluginObj, method) = searchPrioritizedPlugin(assistantId, speech, language)
if pluginObj == None and method == None:
(clazz, method) = getPlugin(speech, language)
if clazz != None and method != None:
logger.debug("Instantiating plugin and method: {0}.{1}".format(clazz.__name__, method.__name__))
pluginObj = clazz()
pluginObj.initialize(method, speech, language, sendObj, sendPlist, assistant, location, alertContext)
#prioritizePluginObject(pluginObj, assistantId)
else:
#reinitialize it
logger.info("Found a matching prioritized plugin")
pluginObj.initialize(method, speech, language, sendObj, sendPlist, assistant, location, alertContext)
return pluginObj
This can be used for reading new messages
I added similar code to my SiriProtocolHandler, however I took a different approach to the alert context, I added it to the assistant object. The alert contexts can then be accessed from the plugin by accessing the
self.assistant.alerts
property from the plugin.
I don't have time to go through and document my changes tonight, but I could tomorrow.
Thanks for idea. It's much easier.
I have added code to the sms plugin Eichhoernchen built to be able to read back new messages, as well as reply to them. I will upload my code and make a pull request for that either tonight or tomorrow.
post it here :) - http://ioshack.org/forums/
For anyone looking for my plugin, seeing as how the ioshack forums are unreliable and the grwh one got spammed, I have uploaded it to my git. Feel free to use, re-use, improve and modify as you wish.
Eric
https://github.com/ericyanush/SiriServerSMSPlugin
ioshack is not unreliable, they where taken down until eich knows what he wants to do with it.
ioshack is aimed for free hosting space atm.
On Jul 11, 2012, at 7:51 PM, Eric Yanush wrote:
For anyone looking for my plugin, seeing as how the ioshack forums are unreliable and the grwh one got spammed, I have uploaded it to my git. Feel free to use, re-use, improve and modify as you wish.
Eric
https://github.com/ericyanush/SiriServerSMSPlugin
Reply to this email directly or view it on GitHub: https://github.com/Eichhoernchen/SiriServerCore/issues/72#issuecomment-6924379