New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SEP1 - New plugin interface #138
Comments
I don't see how defining commands with decorators leads towards that goal, but I approve of both it and the goal regardless. Agree that abstracting fbchat is a good move, in the meantime we can just write a wrapper for it. |
I don't understand how fbchat code is related to chaining together plugin calls, but I'm all for this. Edit: Ah, yeah that was dumb. All plugins tightly depend on fbchat. |
Yeah, I think maybe I did mix whys, but for chaining to work we do need to add our own wrapper, and to do that without dirty hacks we kind of need to make plugins register themselves to steely |
Ideas❌ Make all plugins return a single message.This won't work for a large number of reasons.
✅ Hide the fbchat bot behind a Bot interface.(Then simply inject the bot into the plugin)
Potential interface methods:
// Reacting to messages is kinda difficult to do generically since facebook reacts (angery etc) are niche and don't line up with the reactions you can do on slack. |
@byxor (+ @benmcmahon100 ftb) idk where your "Make all plugins return a single message." idea came from, or how it's related, but regardless, the Bot interface seems to me to be the best direction. Your first point, about plugins being compatible with all of those services, is misguided imo. I think a better phrasing would be "partially compatible", with possible extra functionality on services that allow it. Eg. allow steely to try to add a reaction to a message, and just fail gracefully if that operation isn't supported on that platform. This relates to your note at the end.
If we do the above, I think there's not really any adjustment required for plugins (your second point mentions this), if in the interim we create a Bot interface that mostly mirrors the fbchat API. Later on we can worry about refactors and moving away from that. Not sure what the |
Because a lot of the plugins call For example...
The |
I see two ways to go about implementing the new interface: decorators or an overridden class. Decorators:@steely.command("translate", input_type=steely.previous)
def main(arguments, prev_message):
return translate(arguments, prev_message)
@steely.command("flip", output_type=[steely.image, steely.msg])
def main(args):
result = flip()
return images[result], make_response(result)
@steely.command("buy", parent="linden")
def main(args):
return buy_lindens(args) Decorators was the original proposal and makes steely more involved in how commands operate. Pros:
Cons:
Same structure, new APIdef tranlate(bot, args):
bot.send(do_tranlation(args, bot.prev_message()))
return
def flip_coin(bot, args):
result = flip()
bot.send_image(images{result])
bot.send(make_response(result))
return
def main(bot, args):
if bad_arguments(args):
return
bot.send(sub_command(args[0], args))
return Pros:
Cons:
|
ping @sentriz |
Sorry for responding so quickly without giving everything a read, but... RE: @steely.command("translate", input_type=steely.previous)
def main(arguments, prev_message): Why should a plugin know where its input is coming from? That means you need to write the plugin multiple times to accommodate input from different places. I like the idea of subcommands. RE:
Subcommands are a separate concern. The bot shouldn't have any idea about subcommands; a generic subcommand library should be a dependency of the plugin rather than something tightly coupled to the bot. |
The code examples are very loose and just there to give you an idea, but essentially that just says pass in some input that isn't in the arguments, and could be generalized to that. Steely could pipe in the input from another source, etc. |
Why not just take the input as a parameter? That way we don't need to know where it's coming from, but some higher level piece of code needs to be responsible for passing the correct input in. Where a function gets its input is not the responsibility of that function itself. |
Yeah I mean, that's the general idea. Having it as an input works grand, but with an argument we basically are saying to steely we don't ever take any auxilary input (apart from arguments). This means essentially that it doesn't read from stdin. Like I said though, the exact api for the two code samples isn't super important, and the details can be ironed out once we a general consensus. |
Vague idea/spitballing: Instead of saying That way it's impossible for a plugin to say |
I think Aaron's proposing the |
We can use Dipla's value routing features to implement command chaining. |
As detailed by @sentriz before, we want to modify the core interface to allow people to define commands with decorators.
This is moving towards the goal of chaining multiple steely commands, eg
.slag | .snoop
to get a snoop slag, without intermediate messages.We should write out a few proposals on how we could do this. Personally I think abstracting fbchat away is the way to go.
The text was updated successfully, but these errors were encountered: