Skip to content

Added prefix argument to CommandHandler #1021

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

Closed
wants to merge 2 commits into from

Conversation

JosXa
Copy link
Contributor

@JosXa JosXa commented Feb 25, 2018

This will be useful for making CommandHandlers that do not adhere to the /-prefix convention.
Hashtag commands or ones without any prefix at all become possible through this PR.

Copy link
Member

@tsnoam tsnoam left a comment

Choose a reason for hiding this comment

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

See comments on code.

# it as an empty string prefix.
self.prefix = ''
else:
self.prefix = prefix
Copy link
Member

Choose a reason for hiding this comment

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

  • I don't think prefix should be limited to a single char. Same as you accept an empty string you can accept any string longer than 1 char.

  • Instead of calculating (over and over) the empty_leader during check_update, you can calculate self.leader_len here (at the c'tor) and simplify everything else later on.

  • Calling len(prefix) here will also make the check for None redundant. It will be the one to raise TypeError if necessary.

@wagnerluis1982
Copy link
Contributor

wagnerluis1982 commented Apr 17, 2018

The idea behind this PR is interesting. Since there is two months with no activity, I suppose it's abandoned, so can I assume the work?

@tsnoam
Copy link
Member

tsnoam commented Apr 17, 2018

@wagnerluis1982 Hi,
Thanks for the suggestion. The reason this PR was on hold is because we discussed a different design:

  1. CommandHandler should be implemented strictly for commands as they are defined and supported by bot father.
  2. PrefixHandler (as it would be more appropriate to call the suggested feature here) is nothing more than a convenience on top of RegexHandler.
  3. We have plans to refactor the handler mechanism which will make this PR somewhat of wasted work.

If you want to contribute to the project, feel free to contact me and we can discuss the details. http://t.me/tsnoam

@tsnoam
Copy link
Member

tsnoam commented Apr 17, 2018

@wagnerluis1982 see issue #1026 about the redesign of handlers.

@wagnerluis1982
Copy link
Contributor

@tsnoam thanks for the feedback, I understood the point.

@jsmnbom
Copy link
Member

jsmnbom commented May 22, 2018

Once again thanks for getting us started on this idea.
This PR has been superseded by #1114 - closing.

@jsmnbom jsmnbom closed this May 22, 2018
@github-actions github-actions bot locked and limited conversation to collaborators Aug 21, 2020
@Bibo-Joshi Bibo-Joshi deleted the commandhandler-leading-chars branch November 23, 2020 08:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy