plamoni / SiriProxy

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

Implement a run() method for external usage #546

Open hackworth opened 11 years ago

hackworth commented 11 years ago

I wanted to be able to use my SiriProxy plugins outside of the normal SiriProxy context, pull request adds a run() method for that purpose. Accepts a string input, returns SiriProxy's response from any plugins. I've tested it with an IRC plugin.

require 'siriproxy/command_line'

siri = SiriProxy::CommandLine.new
puts siri.run("test siri proxy")
elvisimprsntr commented 11 years ago

Nice work. We'll pull it in the next update.

Question. I have a few plugging, some with overlapping capability. For example an IPCam plugin which pushes camera images. I often have to duplicate the same functionality in other plugins which also need to push camera images. For example a garage door plugin. I've often wondered if there was a way to call methods in one plugin and return back to the first plugin to eliminate the duplicate methods. Does this allow me to accomplish this?

hackworth commented 11 years ago

This method wouldn't do it, but that should be possible, I'll mock it up as soon as I have time and let you know.

hackworth commented 11 years ago

I'm fairly new to Ruby, but I think putting your common methods into a ruby module would allow you to share those methods. I've been experimenting with calling other listen_for blocks, outside of the current plugin, which is easy enough.

cora = SiriProxy::PluginManager.new
cora.process("watch battlestar galactica")

Obviously you can pass in whatever text or variable to cora.process. If you just run

process("watch battlestar galactica")

It's only able to run listen_for blocks within the same plugin.

I'm using this functionality in a home automation plugin I've been writing to do multiple things at once, such as "turn on bedroom and turn off hallway and watch battlestar galactica" plugin is here

elvisimprsntr commented 11 years ago

Thanks. I'll try it when I'm back home.