ASU-CodeDevils / flameboi-slack-api

A Slackbot API for the old CodeDevils Slack server.
https://asu-codedevils.github.io/flameboi-slack-api/
MIT License
4 stars 0 forks source link

**Add slash commands** #24

Open stucamp opened 4 years ago

stucamp commented 4 years ago
stucamp commented 4 years ago

To this point... the eventsAPI has a event emitter for mentions of the bot... instead of the basic /commands I think we should implement most of the functionality to `@flameboi ' instead. This keeps us from having to manually enter each command into the app management console on the website and allows us to reseve the / feature for specific tasks/duties

KevinThePepper commented 4 years ago

Mentions work almost as well. Only thing you'll have to account for is someone mentioning the bot mid-sentence (i.e. I think @flameboi is a great bot). Past that, it'll have the same functionality.

I think what you're thinking though is entering a bunch of different slash commands, as opposed to just a /flameboi command. If you just have a /flameboi slash command, it's one endpoint and you don't have to change any endpoints to it. You can simply validate the text after the flameboi command, and even give a default help message if someone doesn't enter a command you're use to.

For example, you have a /covidstats and /dadjoke slash commands, but instead, you could just do /flameboi covidstats and /flameboi dadjoke, and accomplish the same thing, but route everything to one endpoint.

stucamp commented 4 years ago

True. I keep forgetting about that, lol. I guess the only thing I'm trying to say is we should decide how we want to use each mechanism. There are def some diffences, such as while eventsAPI seems a quite a bit more versatile, there may be instances where an event subscription isn't available or the fact that slash commands aren't constrained to channels the bit has been invited to and are workspace wide... Def something to think about.

bananabrann commented 4 years ago

@stucamp Are you working on this one?

@KevinThePepper To prevent the bot from activating mid-sentence like in your example, does it make sense for like "If what follows is not contain recognized command (array or something), exit"?

KevinThePepper commented 4 years ago

Definitely, you can account for mid-message mentions, and even with slash commands like I'm suggesting you'd have to worry about validating user input. Just with the single end-point slash command you can treat it as more of a plug-in that anyone can contribute to. I'm willing to discuss my idea with you if it seems too wild

stucamp commented 4 years ago

Yes and no. I'm kind mid refactor on my branch (started playing with it on the couch and have a solid direction). Doing a pretty beefy rethink of the file/project structure to enable a bit of modularity. The slash commands themselves should be fairly simple to add in to the bot given we can make a separate flask endpoint for those, which you're correct, will require some input parsing/validation. The goal of the refactor is to essentially get the skeleton of the bot to be able to add/remove both pretty easily while containing the specific functions such a command requires in its own modular file.

That's said you're absolutely right in that any command, particularly one with parameters will require some sort of inout validation/parsing. A little less so with slash commands as slack will only trigger those at the begining of a message.

stucamp commented 4 years ago

@bananabrann have added a flask endpoint to enable the slash commands feature from slack at the same base url as the rest of the bot. also, added it to routing and events handling in my upcoming beefy refactor. if you have a change take a peak at my branch and let me know what you think of the upcoming project/file structure... not nearly done yet, but the bones are there and you can probably get an idea of what i'm angling toward.