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

Simplify handlers (internal only) #162

Merged
merged 5 commits into from
May 1, 2018
Merged

Simplify handlers (internal only) #162

merged 5 commits into from
May 1, 2018

Conversation

rougeth
Copy link
Owner

@rougeth rougeth commented Apr 30, 2018

This pull request make easier to create or extend handlers. Now Bottery choose the view to respond a new message according to a list of handler instances.

Closes: #161

@rougeth rougeth force-pushed the simplify-handlers branch from df5eb88 to ecf2364 Compare April 30, 2018 12:36
@@ -19,22 +19,23 @@ If the bot receives a message that is exactly equal to `ping` the response will

Bottery has the following handlers available:


Copy link
Collaborator

Choose a reason for hiding this comment

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

why two lines?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Two lines between sections. I changed it a bit, is it better?

Create a new handler
--------------------

The interface of a handler is quite simple. To create a new one, everything needed is a class with a method called ``match`` and an attribute called ``view``. The method ``match`` define if that handler should be used or not to respond to the new message. It must receive a ``Message`` as a parameter and return a boolean. The attribute ``view`` will be used if the ``match`` returns ``True``.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is better to use "the handler's structure" instead of interface


.. code-block:: python

class LongTextHandler:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think i would be clearer if the example had a pattern to compare, like StartsWithHandler or something similar. I got confused if this did the same thing.

@rougeth rougeth force-pushed the simplify-handlers branch from ecf2364 to 7781358 Compare May 1, 2018 16:44
@rougeth rougeth merged commit 5f88e08 into master May 1, 2018
@rougeth rougeth deleted the simplify-handlers branch May 1, 2018 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants