Skip to content
This repository has been archived by the owner on Jan 28, 2023. It is now read-only.

Implement a run() method for external usage #546

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hackworth
Copy link

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")

Accepts a string input, returns the response from any SiriProxy plugins.
@elvisimprsntr
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Author

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
Copy link
Collaborator

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants