mirror of
https://github.com/Steffo99/greed.git
synced 2024-11-25 07:14:18 +00:00
More work on the invoice payload handling
This commit is contained in:
parent
4c074ac199
commit
cf896a8549
2 changed files with 19 additions and 1 deletions
15
core.py
15
core.py
|
@ -111,6 +111,21 @@ def main():
|
||||||
continue
|
continue
|
||||||
# Forward the update to the worker
|
# Forward the update to the worker
|
||||||
receiving_worker.queue.put(update)
|
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 there were any updates...
|
||||||
if len(updates):
|
if len(updates):
|
||||||
# Mark them as read by increasing the update_offset
|
# Mark them as read by increasing the update_offset
|
||||||
|
|
|
@ -84,3 +84,6 @@ error_payment_amount_over_max = "⚠️ Il massimo di fondi che possono essere a
|
||||||
|
|
||||||
# Error: add funds amount under min
|
# 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."
|
Loading…
Reference in a new issue