1
Fork 0
mirror of https://github.com/Steffo99/greed.git synced 2024-11-21 21:44:19 +00:00

Reformat file

This commit is contained in:
Steffo 2020-04-23 17:47:19 +02:00
parent e663da5adc
commit bd44942eca

View file

@ -67,7 +67,6 @@ class Worker(threading.Thread):
def __repr__(self): def __repr__(self):
return f"<{self.__class__.__qualname__} {self.chat.id}>" return f"<{self.__class__.__qualname__} {self.chat.id}>"
# noinspection PyBroadException
def run(self): def run(self):
"""The conversation code.""" """The conversation code."""
# Welcome the user to the bot # Welcome the user to the bot
@ -104,6 +103,7 @@ class Worker(threading.Thread):
if will_be_owner: if will_be_owner:
log.warning(f"User was auto-promoted to Admin as no other admins existed: {self.user}") log.warning(f"User was auto-promoted to Admin as no other admins existed: {self.user}")
# Capture exceptions that occour during the conversation # Capture exceptions that occour during the conversation
# noinspection PyBroadException
try: try:
# If the user is not an admin, send him to the user menu # If the user is not an admin, send him to the user menu
if self.admin is None: if self.admin is None:
@ -118,6 +118,7 @@ class Worker(threading.Thread):
self.__admin_menu() self.__admin_menu()
except Exception: except Exception:
# Try to notify the user of the exception # Try to notify the user of the exception
# noinspection PyBroadException
try: try:
self.bot.send_message(self.chat.id, strings.fatal_conversation_exception) self.bot.send_message(self.chat.id, strings.fatal_conversation_exception)
except Exception: except Exception:
@ -533,8 +534,9 @@ class Worker(threading.Thread):
# Suggest payment for missing credit value if configuration allows refill # Suggest payment for missing credit value if configuration allows refill
if configloader.config["Credit Card"]["credit_card_token"] != "" \ if configloader.config["Credit Card"]["credit_card_token"] != "" \
and configloader.config["Appearance"]["refill_on_checkout"] == 'yes' \ and configloader.config["Appearance"]["refill_on_checkout"] == 'yes' \
and credit_required <= utils.Price(int(configloader.config["Credit Card"]["max_amount"])) \ and utils.Price(int(configloader.config["Credit Card"]["min_amount"])) <= \
and credit_required >= utils.Price(int(configloader.config["Credit Card"]["min_amount"])): credit_required <= \
utils.Price(int(configloader.config["Credit Card"]["max_amount"])):
self.__make_payment(utils.Price(credit_required)) self.__make_payment(utils.Price(credit_required))
# If afer requested payment credit is still insufficient (either payment failure or cancel) # If afer requested payment credit is still insufficient (either payment failure or cancel)
if self.user.credit < self.__get_cart_value(cart): if self.user.credit < self.__get_cart_value(cart):
@ -832,7 +834,7 @@ class Worker(threading.Thread):
self.bot.send_message(self.chat.id, strings.conversation_admin_select_product, self.bot.send_message(self.chat.id, strings.conversation_admin_select_product,
reply_markup=telegram.ReplyKeyboardMarkup(keyboard, one_time_keyboard=True)) reply_markup=telegram.ReplyKeyboardMarkup(keyboard, one_time_keyboard=True))
# Wait for a reply from the user # Wait for a reply from the user
selection = self.__wait_for_specific_message(product_names, cancellable = True) selection = self.__wait_for_specific_message(product_names, cancellable=True)
# If the user has selected the Cancel option... # If the user has selected the Cancel option...
if isinstance(selection, CancelSignal): if isinstance(selection, CancelSignal):
# Exit the menu # Exit the menu
@ -956,7 +958,7 @@ class Worker(threading.Thread):
self.bot.send_message(self.chat.id, strings.conversation_admin_select_product_to_delete, self.bot.send_message(self.chat.id, strings.conversation_admin_select_product_to_delete,
reply_markup=telegram.ReplyKeyboardMarkup(keyboard, one_time_keyboard=True)) reply_markup=telegram.ReplyKeyboardMarkup(keyboard, one_time_keyboard=True))
# Wait for a reply from the user # Wait for a reply from the user
selection = self.__wait_for_specific_message(product_names, cancellable = True) selection = self.__wait_for_specific_message(product_names, cancellable=True)
if isinstance(selection, CancelSignal): if isinstance(selection, CancelSignal):
# Exit the menu # Exit the menu
return return