mirror of
https://github.com/Steffo99/greed.git
synced 2024-11-21 13:34:18 +00:00
Delete cancelled refund messages
This commit is contained in:
parent
62056f57ad
commit
13ca9c5391
2 changed files with 9 additions and 2 deletions
5
utils.py
5
utils.py
|
@ -109,7 +109,6 @@ def telegram_html_escape(string: str):
|
|||
.replace('"', """)
|
||||
|
||||
|
||||
|
||||
def catch_telegram_errors(func):
|
||||
"""Decorator, can be applied to any function to retry in case of Telegram errors."""
|
||||
def result_func(*args, **kwargs):
|
||||
|
@ -186,4 +185,8 @@ class DuckBot:
|
|||
def send_chat_action(self, *args, **kwargs):
|
||||
return self.bot.send_chat_action(*args, **kwargs)
|
||||
|
||||
@catch_telegram_errors
|
||||
def delete_message(self, *args, **kwargs):
|
||||
return self.bot.delete_message(*args, **kwargs)
|
||||
|
||||
# TODO: add more methods
|
||||
|
|
|
@ -874,11 +874,13 @@ class ChatWorker(threading.Thread):
|
|||
# If the user pressed the refund order button, refund the order...
|
||||
elif update.data == "order_refund":
|
||||
# Ask for a refund reason
|
||||
self.bot.send_message(self.chat.id, strings.ask_refund_reason, reply_markup=cancel_keyboard)
|
||||
reason_msg = self.bot.send_message(self.chat.id, strings.ask_refund_reason, reply_markup=cancel_keyboard)
|
||||
# Wait for a reply
|
||||
reply = self.__wait_for_regex("(.*)", cancellable=True)
|
||||
# If the user pressed the cancel button, cancel the refund
|
||||
if isinstance(reply, CancelSignal):
|
||||
# Delete the message asking for the refund reason
|
||||
self.bot.delete_message(self.chat.id, reason_msg.message_id)
|
||||
continue
|
||||
# Mark the order as refunded
|
||||
order.refund_date = datetime.datetime.now()
|
||||
|
@ -897,6 +899,8 @@ class ChatWorker(threading.Thread):
|
|||
# Notify the user of the refund
|
||||
self.bot.send_message(order.user_id,
|
||||
strings.notification_order_refunded.format(order=order.get_text(self.session)))
|
||||
# Notify the admin of the refund
|
||||
self.bot.send_message(self.chat.id, strings.success_order_refunded.format(order_id=order.order_id))
|
||||
|
||||
def __create_transaction(self):
|
||||
"""Edit manually the credit of an user."""
|
||||
|
|
Loading…
Reference in a new issue