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

Finish and Refactor Predicate Utility #2169

Conversation

Tobotimus
Copy link
Member

  • Uses classmethods to create predicates
  • Classmethods allow using a combination of different parameters to describe context
  • Some predicates assign a captured result to the predicate object on success
  • Added ReactionPredicate equivalent to MessagePredicate
  • Added utils.menus.start_adding_reactions, a non-blocking method for adding reactions asynchronously
  • Added documentation
  • Uses these new utils throughout the core bot
    Happened to also find some bugs in places, and places where we were waiting for events without catching asyncio.TimeoutError

* Use classmethods to create predicates directly

* Some predicates assign a `result` to the predicate object on success

* Add ReactionPredicate equivalent

* Add `utils.menus.start_adding_reactions`

* Add documentation for predicates module

* Use new utils throughout the core bot
Happened to also find some bugs in places, and places where we were waiting for events without catching asyncio.TimeoutError...

* Rename `match` attribute to `result`.
@Tobotimus Tobotimus added QA: Needed Type: Feature New feature or request. labels Oct 2, 2018
@Tobotimus Tobotimus added this to the RC 1 milestone Oct 2, 2018
@Tobotimus Tobotimus requested a review from Redjumpman October 2, 2018 06:43
This attribute should always be an empty string

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
@Redjumpman
Copy link
Member

Holy crap dude. This is amazing. I can't believe you took my tiny enhancement and turned it into this robust utility. I'm currently going through all of the methods testing them separately, and then checking the implementation applied to core. Also the documentation is 💯 .

Copy link
Member

@Redjumpman Redjumpman left a comment

Choose a reason for hiding this comment

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

This tested out fine with me. The only thing I saw that could be changed is in downloader. We are using MessagePredicate.equal_to where a MessagePredicate.lower_equal_to might be more appropriate with the target string becoming "i agree".

@Tobotimus
Copy link
Member Author

@Redjumpman Thanks for reviewing 😃

@Tobotimus Tobotimus merged commit dea9dde into Cog-Creators:V3/feature/predicates Oct 5, 2018
@Tobotimus Tobotimus deleted the V3/feature/predicates-classmethods branch October 5, 2018 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New feature or request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants