From b0186edd4207ea2240195ad93a6dd26f5db63936 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 15 Feb 2018 08:49:04 +0100 Subject: [PATCH] Some bugfixes --- core.py | 3 +++ strings.py | 9 +++------ worker.py | 9 +++------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/core.py b/core.py index ea04b1f..b06b702 100644 --- a/core.py +++ b/core.py @@ -29,6 +29,9 @@ def main(): # TimedOut / NetworkError counter, increases by 1 every time get_updates fails and resets to 0 when it succedes timed_out_counter = 0 + # Notify on the console that the bot is starting + print("greed-bot is now starting!") + # Main loop of the program while True: # Get a new batch of 100 updates and mark the last 100 parsed as read diff --git a/strings.py b/strings.py index 7c7cbf3..989129f 100644 --- a/strings.py +++ b/strings.py @@ -95,7 +95,7 @@ ask_product_description = "Quale deve essere la descrizione del prodotto?" # Add product: price? ask_product_price = "Quanto deve costare il prodotto?\n" \ - "Scrivi skip se vuoi che il prodotto non sia ancora in vendita." + "Scrivi X se vuoi che il prodotto non sia ancora in vendita." # Add product: image? ask_product_image = "Che immagine vuoi che abbia il prodotto?" @@ -134,11 +134,8 @@ bot_info = 'Questo bot utilizza gree ' Affero General Public License 3.0.\n' \ 'Il codice sorgente di questa versione è disponibile qui.\n' -# Success: product has been added to the database -success_product_added = "✅ Il prodotto è stato aggiunto con successo!" - -# Success: product has been added to the database -success_product_edited = "✅ Il prodotto è stato modificato con successo!" +# Success: product has been added/edited to the database +success_product_edited = "✅ Il prodotto è stato aggiunto/modificato con successo!" # Error: message received not in a private chat error_nonprivate_chat = "⚠️ Questo bot funziona solo in chat private." diff --git a/worker.py b/worker.py index 634efbd..3a2009e 100644 --- a/worker.py +++ b/worker.py @@ -374,7 +374,7 @@ class ChatWorker(threading.Thread): # Otherwise, set the fee to 0 to ensure no accidental discounts are applied total_fee = 0 # Create the invoice keyboard - inline_keyboard = telegram.InlineKeyboardMarkup([[telegram.InlineKeyboardButton(strings.menu_pay)], + inline_keyboard = telegram.InlineKeyboardMarkup([[telegram.InlineKeyboardButton(strings.menu_pay, pay=True)], [telegram.InlineKeyboardButton(strings.menu_cancel, callback_data="cmd_cancel")]]) # The amount is valid, send the invoice self.bot.send_invoice(self.chat.id, @@ -504,7 +504,7 @@ class ChatWorker(threading.Thread): # Wait for an answer description = self.__wait_for_regex(r"(.*)", cancellable=bool(product)) # Ask for the product price - self.bot.send_message(self.chat.id, strings.ask_product_price) + self.bot.send_message(self.chat.id, strings.ask_product_price, parse_mode="HTML") # Display the current name if you're editing an existing product if product: self.bot.send_message(self.chat.id, strings.edit_current_value.format(value=(strings.currency_format_string.format(symbol=strings.currency_symbol, value=(product.price / (10 ** int(configloader.config["Payments"]["currency_exp"]))))) if product.price is not None else 'Non in vendita'), parse_mode="HTML", reply_markup=cancel) @@ -555,10 +555,7 @@ class ChatWorker(threading.Thread): # Commit the session changes self.session.commit() # Notify the user - if product: - self.bot.send_message(self.chat.id, strings.success_product_edited) - else: - self.bot.send_message(self.chat.id, strings.success_product_added) + self.bot.send_message(self.chat.id, strings.success_product_edited) def __orders_menu(self): raise NotImplementedError()