Invoice Payload Filtering#3773
Invoice Payload Filtering#3773thefunkycat wants to merge 7 commits intopython-telegram-bot:masterfrom
Conversation
|
pytest seems to be angry @harshil21 |
Sorry, #3769 is fixing that |
…ring"" This reverts commit 87ef077.
|
trusted Github's automatic conflict resolution for the merge conflict, never again. fixed manually now |
There was a problem hiding this comment.
Hi, thanks for the PR and sorry for the late review. It's mostly well done except you also need to write tests for this. See our testing guide and Checklist for PRs to know what to complete. Please also run the doc build locally to make sure it passes.
| :class:`telegram.ext.ConversationHandler`. | ||
| pattern (:obj:`str` | :func:`re.Pattern <re.compile>` | :obj:`callable` | :obj:`type`, \ | ||
| optional): | ||
| Pattern to test :attr:`telegram.Update.pre_checkout_query.invoice_payload` against. If |
There was a problem hiding this comment.
| Pattern to test :attr:`telegram.Update.pre_checkout_query.invoice_payload` against. If | |
| Pattern to test :attr:`telegram.Update.pre_checkout_query.invoice_payload <telegram.PreCheckoutQuery.invoice_payload>` against. If |
don't commit these directly from Github, since it will exceed the line limit. Do it in the IDE so you can correct it
| optional): | ||
| Pattern to test :attr:`telegram.Update.pre_checkout_query.invoice_payload` against. If | ||
| a string or a regex pattern is passed, :func:`re.match` is used on | ||
| :attr:`telegram.Update.pre_checkout_query.invoice_payload` to determine if an update |
There was a problem hiding this comment.
| :attr:`telegram.Update.pre_checkout_query.invoice_payload` to determine if an update | |
| :attr:`telegram.Update.pre_checkout_query.invoice_payload <telegram.PreCheckoutQuery.invoice_payload>` to determine if an update |
| callback (:term:`coroutine function`): The callback function for this handler. | ||
| block (:obj:`bool`): Determines whether the callback will run in a blocking way.. | ||
| pattern (:func:`re.Pattern <re.compile>` | :obj:`callable` | :obj:`type`): Optional. | ||
| Regex pattern to test :attr:`telegram.Update.pre_checkout_query.invoice_payload` |
There was a problem hiding this comment.
| Regex pattern to test :attr:`telegram.Update.pre_checkout_query.invoice_payload` | |
| Regex pattern to test :attr:`telegram.Update.pre_checkout_query.invoice_payload <telegram.PreCheckoutQuery.invoice_payload>` |
| def __init__( | ||
| self, | ||
| callback: HandlerCallback[Update, CCT, RT], | ||
| pattern: Optional[Union[str, Pattern[str]]] = None, |
There was a problem hiding this comment.
| pattern: Optional[Union[str, Pattern[str]]] = None, | |
| pattern: Optional[Union[str, Pattern[str], Callable[[str], Optional[bool]]] = None, |
| if isinstance(pattern, str): | ||
| pattern = re.compile(pattern) | ||
|
|
||
| self.pattern: Optional[Union[str, Pattern[str]]] = pattern |
There was a problem hiding this comment.
| self.pattern: Optional[Union[str, Pattern[str]]] = pattern | |
| self.pattern: Optional[Union[Pattern[str], Callable[[str], Optional[bool]]] = pattern |
| a string or a regex pattern is passed, :func:`re.match` is used on | ||
| :attr:`telegram.Update.pre_checkout_query.invoice_payload` to determine if an update | ||
| should be handled by this handler. | ||
|
|
There was a problem hiding this comment.
please add a .. versionadded:: note here. Search for it in the codebase if you want to know how to add them.
| block (:obj:`bool`): Determines whether the callback will run in a blocking way.. | ||
| pattern (:func:`re.Pattern <re.compile>` | :obj:`callable` | :obj:`type`): Optional. | ||
| Regex pattern to test :attr:`telegram.Update.pre_checkout_query.invoice_payload` | ||
| against. |
There was a problem hiding this comment.
same versionadded note here as well
|
|
||
| class _SuccessfulPayment(MessageFilter): | ||
| __slots__ = () | ||
| class SuccessfulPayment(MessageFilter): |
There was a problem hiding this comment.
please write a docstring for this class. Make sure to include the versionadded
| class SuccessfulPayment(MessageFilter): | ||
| __slots__ = ("strings",) | ||
|
|
||
| def __init__(self, strings: Optional[Union[List[str], Tuple[str, ...]]] = None): |
There was a problem hiding this comment.
| def __init__(self, strings: Optional[Union[List[str], Tuple[str, ...]]] = None): | |
| def __init__(self, invoice_payloads: Optional[Union[List[str], Tuple[str, ...]]] = None): |
explicit naming is better. Change it below also ofc
| return bool(message.successful_payment) | ||
| if self.strings is None: | ||
| return bool(message.successful_payment) | ||
| return message.successful_payment in self.strings if message.successful_payment else False |
There was a problem hiding this comment.
| return message.successful_payment in self.strings if message.successful_payment else False | |
| return message.successful_payment.invoice_payload in self.strings if message.successful_payment else False |
|
@thefunkycat are you still interested in working on this pr? |
|
Closing due to inactivity |
Closes #3752
I've made two commits:
Looking forward to a review, will gladly make any changes required.