Skip to content
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

!learn plugin #36

Open
cbojar opened this issue Sep 11, 2015 · 12 comments
Open

!learn plugin #36

cbojar opened this issue Sep 11, 2015 · 12 comments

Comments

@cbojar
Copy link
Collaborator

cbojar commented Sep 11, 2015

We could write a plugin such that certain privileged users can tell JBot to `!learn command reply with this text" so that we can quickly add static replies for commands that people might be interested in:

<admin> !learn cheese Say cheese!
<user> !cheese
<JBot> Say cheese!

They can be saved in-memory, and so be temporary, or be saved permanently so they might be available longer. Associated would be a !unlearn command command to forget commands once they are no longer needed.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@rikai
Copy link
Owner

rikai commented Aug 20, 2016

This seems like something that might be up @s0ph0s-2's alley. Similar in scope to the live quotes editing, at least nominally.

@s0ph0s-dog
Copy link

@rikai Yup, that's something I could totally do. I think I'll take a look at it tomorrow...

@s0ph0s-dog
Copy link

Actually, you can already do this with the quotes plugin. It registers a handler for !* and checks the bit matched by * against any of the names in the quotes list. So, you could issue !quote add cheese Say cheese! to do the thing laid out in the example.

I see two options here:

  1. I could submit a pull request to alias !quote add to !learn and !quote delete to !unlearn
  2. I could submit a pull request to remove the !* matcher from the quotes plugin and reimplement that functionality as !learn.

@rikai
Copy link
Owner

rikai commented May 27, 2017

I thing i prefer option 2. The proper solution here feels like it would be to split it into it's own thing. I feel like !quote add and !quote delete should be for adding lines to existing quote commands, not create new ones.

As for !learn, i might suggest it be called !command instead. So !command add .

Perhaps we should have an optional "type" argument as well? so we could define the type "quote", which would give the shifted !quote add and !quote remove access to it?

So the TL;DR would be

  1. Split it out
  2. Make !quote add/remove only work with commands of the "quote" type
  3. Probably make quote lines numbered in some way?
  4. use !command instead of !learn when moving the existing functionality.
  5. add optional 'command types', since quotes are a special type of command, as compared to a regular message, which only has one potential output.

Does this sound smart/doable? I'm open to criticism over my suggestions. 📦

@s0ph0s-dog
Copy link

So, would the commands and the quotes be managed from the same plugin file and stored in the same YAML document? It seems to me like the more sustainable option would be to split them out entirely and manage them with completely separate plugins.

@rikai
Copy link
Owner

rikai commented May 27, 2017

Well, my thought was that we might have more command types down the road, so it would make sense to have everything under one roof, so to speak, with the different types doing different sorts of things when defined. Think of it as a sort of meta-plugin, where depending on the command type, it uses a different sub-plugin/codepath. So the existing quotes functionality would become one of those codepaths, the arbitary generic command adding would be another, a future type would be a third, etc

@s0ph0s-dog
Copy link

Ah, okay. I see. I'll get to work on that then!

@s0ph0s-dog
Copy link

s0ph0s-dog commented Jun 2, 2017

I think it might work better if we use !learn rather than !command, !quote, etc. Since this is one plugin, it makes more sense to me to use one root command word to manage it. Plus, this simplifies the implementation; only using one base command means that we don't have to add new match statements every time we want to add a new command type.

Anyone else want to weigh in? I'm certainly open to suggestions.

@rikai
Copy link
Owner

rikai commented Jun 3, 2017

Well, the way i was picturing it was that !command would be the sole place that you would add/remove commands.

The other triggers would be based on whatever you added. thinking further about it I do agree that the existing !quote functionality would be redundant overall. Would make much more sense to do !command <optional type (e.g. 'quote')> <add/remove> .

I've also been considering changing how the quote system works completely, rather than having per-person custom triggers, i've been thinking about just having a simple quote database that pulls random quote using the !quote command, so it might just make sense to keep quotes separate and dump the command types idea entirely and keep the syntax to a super simple !command add instead... Thoughts?

@s0ph0s-dog
Copy link

Just pulling a random quote from among all of the available ones seems like it would be OK to me. However, that breaks some existing functionality (!8ball), which might be a problem. To keep things from changing much on the user side, should the new !command feature support randomly selecting from a collection of replies?

@rikai
Copy link
Owner

rikai commented Jul 25, 2017

I'm still honestly not sure how I wan't to go about this. I've been looking at various other bots across other services and languages for comparison since my last reply and think that integrating quotes into the generic hierarchy might not be the best option after all. It's not commonly handled that way in most other bots and also complicates the potential future syntax. Been evaluating how others do custom commands and quotes among other things, and the one i like the most so far is probably this one.

It breaks down 'arbitrary' commands into four distinct types, Custom Triggers, Custom Repeats, Custom Scheduled, and Auto-Replies. The quotes command is entirely separate from the custom triggers, as are other 'fun' commands, equivalent to !8ball that implement custom functionality, which makes sense as it uses non-generic functionality even though it's doing a semi-similar thing. I think that having generics for most uses cases and implementing special cases in separate plugins makes more sense than trying to bolt all sorts of one-off use cases to the future 'generic' command system instead. That would also allow us to expand on the complexity of specific plugins without having to worry about affecting the 'generics' at all, really.

If you happen to know java, you can probably browse the source to get an idea of how it's done, but i feel like we should probably take a similar approach. If you're amenable to adopting that kind of approach, i can expand further.

@s0ph0s-dog
Copy link

I do happen to know Java, so I'll definitely take a look at how CoeBot does things. I agree, their approach looks like it works well and would also work for Showbot.

I also agree that it seems appropriate to implement one-off, joke features as separate plugins, rather than attempting to shove them all into an over-genericized box. Cinchize makes it rather easy to add new plugins, so it isn't exceedingly difficult to add these features that way. This also seems like a good incentive to figure out how to fix #32, since new plugins can then be dropped in without having to restart Showbot.

If we do choose to implement the 'arbitrary' commands the same way CoeBot does, what happens to the current quotes behavior? !8ball and !rms will have to become their own plugins — what else does JB use the quotes for?

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

No branches or pull requests

3 participants