rocdev-foundation / medera

Is a chat bot the new "Hello, World"?
GNU General Public License v3.0
1 stars 2 forks source link

Define the command syntax #14

Closed dantswain closed 7 years ago

dantswain commented 7 years ago

I think it would be helpful to have at least an initial design of the command syntax before trying to wire up #9. We talked through this at one of the meetups but I don't have a picture of the whiteboard or anything and it might be good to write it down somewhere.

dantswain commented 7 years ago

@geowa4 did you take a snapshot of the whiteboard with the commands on it?

geowa4 commented 7 years ago

By example:

# list all containers on a host
!List-DockerContainers host

# show details about a container, matched by name
!Show-DockerContainer --name registrator

# show uptime across my entire fleet
!Show-Uptime

Commands and options must be case insensitive. The values provided for each option must be sent as received. Use either single- or double-quotes to group multi-word option values.

More generically,

<command-prefix><command> [<host>] [--<option> [<option-value>]]
dantswain commented 7 years ago

So you want a posix-style command? I think that's reasonable, I'm just asking for verification purposes.

What do you think about @bot (substitute whatever it's name is - i.e., it's a mention) instead of having a prefix?

@bot list-dockercontainers host
vs
!list-dockercontainers host
dantswain commented 7 years ago

Nice thing about posix-style commands is we get a parser for free. https://hexdocs.pm/elixir/OptionParser.html

dantswain commented 7 years ago

One downside is that unless you go out of your way to change it, macs will change -- to a long dash. Wouldn't be hard to replace that character before parsing, though.

geowa4 commented 7 years ago

I was just thinking we should allow aliased options so -n and --name are the same. Yeah, POSIX is probably a good way to go. Also, I'm purposefully avoiding positional arguments right now.

@bot foo and !foo can be identical. The flexibility is nice. For me, I'm in an environment where people have learned commands like !deploy, which is why I'm really only calling that syntax a must.

dantswain commented 7 years ago

Is the !command syntax directed at the bot in any way or does the bot just monitor the channel and watch for commands that look like that? What happens if there are two bots on the same channel that both listen for !commands?

Should there be a restriction that commands can only be executed in a channel and never in a DM? Or maybe that's configurable per command? It seems like there's a use case for that where accountability is an issue.

geowa4 commented 7 years ago

Yes, "the bot just monitor the channel and watch for commands that look like that". If there are two bots listening for the same thing, they both respond.

Yes, I plan on writing requirement that some commands result in a private response to the individual regardless of origin. I'm also thinking that there should be an option to respond privately unless in a private channel. Should the bot respond with "Responding privately" so the other humans in the chat know it didn't just fail? Regardless, I think this is complicated enough to go into its own issue as soon as I can figure it out.