mirror of
https://github.com/Steffo99/greed.git
synced 2024-11-21 21:44:19 +00:00
This commit is contained in:
parent
bd1b98437d
commit
c9f220ace4
1 changed files with 12 additions and 2 deletions
14
worker.py
14
worker.py
|
@ -246,12 +246,22 @@ class Worker(threading.Thread):
|
|||
# Return the precheckoutquery
|
||||
return update.pre_checkout_query
|
||||
|
||||
def __wait_for_successfulpayment(self) -> telegram.SuccessfulPayment:
|
||||
def __wait_for_successfulpayment(self,
|
||||
cancellable: bool = False) -> Union[telegram.SuccessfulPayment, CancelSignal]:
|
||||
"""Continue getting updates until a successfulpayment is received."""
|
||||
log.debug("Waiting for a SuccessfulPayment...")
|
||||
while True:
|
||||
# Get the next update
|
||||
update = self.__receive_next_update()
|
||||
# If a CancelSignal is received...
|
||||
if isinstance(update, CancelSignal):
|
||||
# And the wait is cancellable...
|
||||
if cancellable:
|
||||
# Return the CancelSignal
|
||||
return update
|
||||
else:
|
||||
# Ignore the signal
|
||||
continue
|
||||
# Ensure the update contains a message
|
||||
if update.message is None:
|
||||
continue
|
||||
|
@ -754,7 +764,7 @@ class Worker(threading.Thread):
|
|||
# Accept the checkout
|
||||
self.bot.answer_pre_checkout_query(precheckoutquery.id, ok=True)
|
||||
# Wait for the payment
|
||||
successfulpayment = self.__wait_for_successfulpayment()
|
||||
successfulpayment = self.__wait_for_successfulpayment(cancellable=False)
|
||||
# Create a new database transaction
|
||||
transaction = db.Transaction(user=self.user,
|
||||
value=int(successfulpayment.total_amount) - fee,
|
||||
|
|
Loading…
Reference in a new issue