Skip to content

Conversation

@jeffffc
Copy link
Contributor

@jeffffc jeffffc commented May 22, 2017

Added PreCheckoutQueryHandler and ShippingQueryHandler

(Re-open after merging #630 to beta branch)

@jsmnbom
Copy link
Member

jsmnbom commented May 24, 2017

Oh I'd already handed adding all the needed filters in #622, but no worries, we'll just fix it in the merge I guess. Also it would probably have been better if you'd opened a new PR with all this extra stuff that did not get merged to the beta branch, instead of just piling it on, but we'll figure something out :)
EDIT: sorry, it seems you did commit the other changes to the beta branch, pardon me

@jsmnbom jsmnbom mentioned this pull request Jun 2, 2017
@tsnoam
Copy link
Member

tsnoam commented Jun 2, 2017

@jeffffc

  1. Would you mind merging from master?
  2. When (& after) you merge please note the convention we use at functions like answer_shipping_query():
    When checking if an optional parameter was supplied we compare it to None like this:
if ok is not None:
    do_something()

It's an important semantic difference as you might want to know that ok is actually False in contrary to never supplied.

jeffffc added 2 commits June 3, 2017 01:09
# Conflicts:
#	telegram/bot.py
#	telegram/message.py
#	telegram/precheckoutquery.py
#	telegram/shippingquery.py
Merge from master and resolve conflicts
@jeffffc
Copy link
Contributor Author

jeffffc commented Jun 2, 2017

@tsnoam I have just resolved the conflicts and merged from master, please do tell me if there is any more problem
and yea it was my first time doing such coding, thanks for the advice, it helps me a lot also

Copy link
Member

@jsmnbom jsmnbom left a comment

Choose a reason for hiding this comment

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

All in all looks good ^^
I've added a few comments in the code


game = _Game()

class _SuccessfulPayment(BaseFilter):
Copy link
Member

Choose a reason for hiding this comment

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

This filter seems to be duplicated as it's been added in another commit too ( see further down)

left_chat_participant (:class:`telegram.User`): Use `left_chat_member`
instead.
<<<<<<<<< Temporary merge branch 1
Copy link
Member

@jsmnbom jsmnbom Jun 2, 2017

Choose a reason for hiding this comment

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

Something weird happened here....
I think it can all just be deleted tbh :/

self.assertTrue(Filters.successful_payment(self.message))
self.message.successful_payment = None
self.assertFalse(Filters.successful_payment(self.message))

Copy link
Member

Choose a reason for hiding this comment

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

Could you add a test for invoice too? I know you didn't actually add the filter, but i just saw that it was missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, meanwhile please check with the updated codes again, thanks a lot!

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.

@jeffffc
Thank you for your contribution, it is highly appreciated.
I have left several comments on the code. Please take a look. Some of them are nitpicks, but should be quick fixes while you're fixing the more substantial parts.

telegram/bot.py Outdated
data['need_name'] = need_name
if need_phone_number is not None:
data['need_phone_number'] = need_phone_number
if need_email:
Copy link
Member

Choose a reason for hiding this comment

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

Please fix to: if need_email is not None

from .shippingquery import ShippingQuery
from .webhookinfo import WebhookInfo
from .gamehighscore import GameHighScore
from .videonote import VideoNote
Copy link
Member

Choose a reason for hiding this comment

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

nitpick:
why remove here and add above? (I prefer the minimal change in diff...)

Copy link
Member

Choose a reason for hiding this comment

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

That's on me... I moved it long ago to fix a circular import issue I had... not sure why it's showing up in this diff though...

Copy link
Member

Choose a reason for hiding this comment

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

well, what every git voodoo happened here, I prefer it not to be part of this PR

telegram/bot.py Outdated
url = '{0]/answerPreCheckoutQuery'.format(self.base_url)

if ((ok is not True and error_message is None) or
(ok is True and error_message is not None)):
Copy link
Member

Choose a reason for hiding this comment

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

In here, for readability I would prefer a shorter form like this:

if not (ok ^ (error_message is None)):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure i could not think of such short version, thank you

raise TelegramError(
'answerPreCheckoutQuery: If ok is True, there should '
'not be error_message; if ok is False, error_message '
'should not be empty')
Copy link
Member

Choose a reason for hiding this comment

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

Open for discussion:
I don't think that we should raise an exception here. If user wants to do unorthodox things, he might know better than us. At most I would issue a warning here.

Copy link
Member

Choose a reason for hiding this comment

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

Warning seems better... especially since we don't raise errors anywhere else if arguments are wrong, so it would be a bit strange to do it here imo

Copy link
Member

Choose a reason for hiding this comment

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

I'm ok with a warning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay for this one i believe i checked with the other existing methods beforehand about these mutual exclusive parameters
i raise exception there was because i was following edit_message_caption and similar ones with either inline messages or normal messages
what do you guys think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tsnoam @bomjacob what do you guys think about this?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm.. you seen to be correct... I don't really have a preference either way then... It's your call @tsnoam

Copy link
Member

Choose a reason for hiding this comment

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

@jeffffc
lol... edit_message_caption exception is my doing. lets keep it that way.


def check_update(self, update):
if isinstance(update, Update) and update.pre_checkout_query:
return True
Copy link
Member

Choose a reason for hiding this comment

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

too long.... this would be sufficient:

return isinstance(update, Update) and update.pre_checkout_query


def check_update(self, update):
if isinstance(update, Update) and update.shipping_query:
return True
Copy link
Member

Choose a reason for hiding this comment

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

same comments like above (too long....)

left_chat_participant (:class:`telegram.User`): Use `left_chat_member`
instead.
Copy link
Member

Choose a reason for hiding this comment

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

please don't remove that line.

total_amount (int): Total price in the smallest units of the currency (integer)
invoice_payload (str): Bot specified invoice payload
Keyword Args:
Copy link
Member

Choose a reason for hiding this comment

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

These are not Keyword Args in the sense of how documentation is generated. Please remove.
Also, bot is missing from the docstring, please add it..

chosen_inline_result=None,
callback_query=None,
shipping_query=None,
pre_checkout_query=None,
Copy link
Member

Choose a reason for hiding this comment

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

For backward compatibility (if some1 for any reason, decided to use Update directly) please add the new parameters to the end (just before **kwargs).

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.

I removed some of my comments. They were wrong.

@tsnoam
Copy link
Member

tsnoam commented Jun 7, 2017

@jeffffc
I'm sorry for the delay in my response, I had several busy days.
I responded to your question above.

@jeffffc
Copy link
Contributor Author

jeffffc commented Jun 8, 2017

@tsnoam It's alright!
and @bomjacob I pushed the fixes already, please have a brief check, thanks!

@tsnoam
Copy link
Member

tsnoam commented Jun 9, 2017

LGTM. Waiting for travis before merging.

@tsnoam tsnoam merged commit da8a3ce into python-telegram-bot:master Jun 9, 2017
@tsnoam
Copy link
Member

tsnoam commented Jun 9, 2017

@jeffffc
Thank you for your contribution.

@jeffffc
Copy link
Contributor Author

jeffffc commented Jun 10, 2017

great, thank you all ;)

@github-actions github-actions bot locked and limited conversation to collaborators Aug 23, 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.

3 participants