Skip to content

Bots: Add default (and other) command dispatch #169

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

neiljp
Copy link
Contributor

@neiljp neiljp commented Nov 25, 2017

This is an alternative implementation of #66 based on discussion in #integrations regarding perceived issues (@showell, @timabbott)

I avoided amending existing bots and instead added a demonstration as a 'helloworld_defaults' bot, which demonstrates the increasing features in subsequent commits:

  • empty ("") and "about" command responses
  • "commands" (uses default commands and those passed in)
  • "help" (default commands, and those passed in with help text)
  • allowing dispatch of all commands through the system
  • a decorator which can be applied to functions, to indicate the command name and help text, and which causes the function to be dispatched if the command matches.

I attempted to develop things in tandem in the test system, but am not fully satisfied with the current system (as per the comments in test_helloworld_defaults).

There is no doc.md file as yet for the new bot, though I can add this easily.

I'm completely open to renaming aspects of the system, but functionally it appears to work fine in tests and with zulip_bot_output.py (or did until I rebased, and now have some kind of storage error? @roberthoenig?)

def __str__(self):
return self.msg

to_dispatch = {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't feel right, having to_dispatch being a module-level variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you prefer this in eg. ExternalBotHandler? Or in a separate class?

Is this approach preferable to #66?

@zulipbot
Copy link
Member

Heads up @neiljp, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the upstream/master branch and resolve your pull request's merge conflicts accordingly.

Extend the dispatch_default_commands function to take an 'other_commands'
parameter, in order to support listing commands which are not just
those listed as default.
To support the help text output, the other_commands parameter to
dispatch_default_commands is now a mapping, and the internal
supported_commands list is now an OrderedDict.
@zulipbot
Copy link
Member

zulipbot commented Dec 8, 2017

Heads up @neiljp, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the upstream/master branch and resolve your pull request's merge conflicts accordingly.

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

Successfully merging this pull request may close these issues.

3 participants