plamoni / SiriProxy

A (tampering) proxy server for Apple's Siri
GNU General Public License v3.0
2.12k stars 343 forks source link

set_state: for the same command. #408

Closed Deanmv closed 11 years ago

Deanmv commented 11 years ago

While creating a plugin, I am working with the set_state: tool.

Is it possible to use this for the same command. e.g something like this:

listen_for /play the song/i do

set_state :playing 

#do some code
request completed
end

Then next have:

listen_for /play the song/i within_state: :playing do
#do some code
set_state nil
request_completed
end

When I do this the "play the song" command is just completely ignored when I run the plugin.

i.e I get

>> play the song
No plugin responded

Anyone got this working?

tcoupe commented 11 years ago

Looks like when a listen_for block gets executed, and the request_completed happens, all other listen_for blocks are skipped (optimized out?). i.e. The spoken phrase was found and satisfied. It seems that the set_state: construct is for consecutive spoken phrases within a greater context.

You might be able to get it working by duplicating function calls within each listen_for block though?

Deanmv commented 11 years ago

Been working on doing a "if this AND this then do this" sort of thing but can't seem to get it to work, do you know of any pointers?

Deanmv commented 11 years ago

Got it working today. Used something along the line of:

@@playhead = "stopped"

listen_for /play the song/i do 

   if @@playhead == "playing" then

      #do this

   else @@playhead == "stopped"

      #do this 
   end
   @@playhead = "playing" #set the playhead to be playing
 end

Was the fact that I hadn't assigned it to be a variable with @@ so it wasn't accessible outside of my if commands originally.