Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow specifying pass_* for handlers in callback annotations #679

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 7 commits into from

Conversation

jsmnbom
Copy link
Member

@jsmnbom jsmnbom commented Jun 20, 2017

I often find it annoying to have to declare a ton of pass_* statements in handlers. This makes it so:

def x(bot, update, args):
    pass

dp.add_handler(CommandHandler('test', x, pass_args=True))

and

def x(bot, update, args: Args):
    pass

dp.add_handler(CommandHandler('test', x))

are equal.


Following annotations work

  • Args
  • Groups (regex)
  • Groupdict (regex)
  • JobQueue
  • UpdateQueue
  • ChatData
  • UserData

I've changed code such that these types are actually passed to the callback methods, so typecheckers that check annotations are happy.


One more this this allows you to you is have something like:

def x(b, u, g: Groups, gd: Groupdict):
    pass

dp.add_handler(RegexHandler('(test)(?P<number>\d+)', x))

Where the group and groupdict arguments can have other names (something that's always worked wih bot and update).

jsmnbom added a commit that referenced this pull request Jun 30, 2017
- Add until_date to kick_chat_member
- Add restrict_chat_member
- Add promote_chat_member
- Add export_chat_invite_link
- Add set_chat_photo

refs #679
jsmnbom added a commit that referenced this pull request Jun 30, 2017
- Add delete_chat_photo
- Add set_chat_title
- Add set_chat_description
- Add pin_chat_message
- Add unpin_chat_message

refs #679
jsmnbom added a commit that referenced this pull request Jun 30, 2017
- Add until_date, can_be_edited, can_change_info, can_post_messages, can_edit_messages, can_delete_messages, can_invite_users, can_restrict_members, can_pin_messages, can_promote_members, can_send_messages, can_send_media_messages, can_send_other_messages and can_add_web_page_previews to ChatMember
- Add photo, description and invite_link to Chat
- Move _totimestamp and _fromtimestamp from Message to utils.helpers since it's now needed more than once place

refs #679
@jsmnbom
Copy link
Member Author

jsmnbom commented Aug 12, 2017

Closing due to lack of interest (PR's shouldn't be long standing)

@jsmnbom jsmnbom closed this Aug 12, 2017
@jsmnbom jsmnbom deleted the pass-annotations branch December 12, 2017 18:26
@github-actions github-actions bot locked and limited conversation to collaborators Aug 22, 2020
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.

1 participant