1
Fork 0
mirror of https://github.com/Steffo99/greed.git synced 2024-11-29 00:54:18 +00:00

More work on the invoice payload handling

This commit is contained in:
Steffo 2018-01-07 23:10:28 +01:00
parent 4c074ac199
commit cf896a8549
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: C27544372FBB445D
2 changed files with 19 additions and 1 deletions

15
core.py
View file

@ -111,6 +111,21 @@ def main():
continue
# Forward the update to the worker
receiving_worker.queue.put(update)
# If the update is a precheckoutquery, ensure it hasn't expired before forwarding it
if update.pre_checkout_query is not None:
# Forward the update to the corresponding worker
receiving_worker = chat_workers.get(update.pre_checkout_query.from_user.id)
# Check if it's the active invoice for this chat
if receiving_worker is None or update.pre_checkout_query.payload != receiving_worker.invoice_payload:
# Notify the user that the invoice has expired
try:
bot.answer_pre_checkout_query(update.pre_checkout_query.id, ok=False, error_message=strings.error_invoice_expired)
except telegram.error.BadRequest:
print(f"ERROR: pre_checkout_query expired before an answer could be sent")
# Go to the next update
continue
# Forward the update to the worker
receiving_worker.queue.put(update)
# If there were any updates...
if len(updates):
# Mark them as read by increasing the update_offset

View file

@ -83,4 +83,7 @@ error_no_worker_for_chat = "⚠️ La conversazione con il bot è interrotta.\n"
error_payment_amount_over_max = "⚠️ Il massimo di fondi che possono essere aggiunti in una singola transazione è {max_amount}."
# Error: add funds amount under min
error_payment_amount_under_min = "⚠️ Il minimo di fondi che possono essere aggiunti in una singola transazione è {min_amount}."
error_payment_amount_under_min = "⚠️ Il minimo di fondi che possono essere aggiunti in una singola transazione è {min_amount}."
# Error: the invoice has expired and can't be paid
error_invoice_expired = "⚠️ Questo pagamento è scaduto ed è stato annullato. Se vuoi ancora aggiungere fondi, usa l'opzione Aggiungi fondi del menu."