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

Implement a command handler #2

Open
3 tasks
DrFrankenstein opened this issue Sep 23, 2019 · 0 comments
Open
3 tasks

Implement a command handler #2

DrFrankenstein opened this issue Sep 23, 2019 · 0 comments
Labels
bot Issues targeting the bot module enhancement New feature or request
Milestone

Comments

@DrFrankenstein
Copy link
Owner

DrFrankenstein commented Sep 23, 2019

Who: Bot users.
When: A command is posted in chat.
What: Parses the command and finds a suitable handler for it.
Why: So that the bot can accept commands from users.
Points: 5

Acceptance Criteria

  • Detects all messages starting with the trigger.
    • That trigger is configured under the "trigger" key of the config file.
  • Allows modules to register commands with names and hanglers.
  • Looks for and calls that handler when the command is posted in chat.

Example

  • Config file contains: trigger: "!".
  • A user posts !roll d6.
    The bot should find a command handler for roll and call it with argument d6.

Technical discussion

A command record should contain:

  • The command name
  • The number of arguments
  • A pointer to the handler to call.

When parsing the command, arguments would be split on whitespace until the argument count is reached. If more whitespace is found, it becomes part of the last argument. For example, if command addquote takes 2 arguments, then !addquote somedude My password is hunter2 would be parsed as

command: "addquote"
arguments: ["somedude", "My password is hunter2"]
@DrFrankenstein DrFrankenstein added the enhancement New feature or request label Sep 23, 2019
@DrFrankenstein DrFrankenstein added this to the mvp milestone Sep 23, 2019
@DrFrankenstein DrFrankenstein added the bot Issues targeting the bot module label Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot Issues targeting the bot module enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant