mirror of
https://github.com/Steffo99/greed.git
synced 2024-11-22 05:54:18 +00:00
Some bugfixes
This commit is contained in:
parent
9017680044
commit
b0186edd42
3 changed files with 9 additions and 12 deletions
3
core.py
3
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
|
# TimedOut / NetworkError counter, increases by 1 every time get_updates fails and resets to 0 when it succedes
|
||||||
timed_out_counter = 0
|
timed_out_counter = 0
|
||||||
|
|
||||||
|
# Notify on the console that the bot is starting
|
||||||
|
print("greed-bot is now starting!")
|
||||||
|
|
||||||
# Main loop of the program
|
# Main loop of the program
|
||||||
while True:
|
while True:
|
||||||
# Get a new batch of 100 updates and mark the last 100 parsed as read
|
# Get a new batch of 100 updates and mark the last 100 parsed as read
|
||||||
|
|
|
@ -95,7 +95,7 @@ ask_product_description = "Quale deve essere la descrizione del prodotto?"
|
||||||
|
|
||||||
# Add product: price?
|
# Add product: price?
|
||||||
ask_product_price = "Quanto deve costare il prodotto?\n" \
|
ask_product_price = "Quanto deve costare il prodotto?\n" \
|
||||||
"Scrivi <code>skip</code> se vuoi che il prodotto non sia ancora in vendita."
|
"Scrivi <code>X</code> se vuoi che il prodotto non sia ancora in vendita."
|
||||||
|
|
||||||
# Add product: image?
|
# Add product: image?
|
||||||
ask_product_image = "Che immagine vuoi che abbia il prodotto?"
|
ask_product_image = "Che immagine vuoi che abbia il prodotto?"
|
||||||
|
@ -134,11 +134,8 @@ bot_info = 'Questo bot utilizza <a href="https://github.com/Steffo99/greed">gree
|
||||||
' <a href="https://github.com/Steffo99/greed/blob/master/LICENSE">Affero General Public License 3.0</a>.\n' \
|
' <a href="https://github.com/Steffo99/greed/blob/master/LICENSE">Affero General Public License 3.0</a>.\n' \
|
||||||
'Il codice sorgente di questa versione è disponibile <i>qui</i>.\n'
|
'Il codice sorgente di questa versione è disponibile <i>qui</i>.\n'
|
||||||
|
|
||||||
# Success: product has been added to the database
|
# Success: product has been added/edited to the database
|
||||||
success_product_added = "✅ Il prodotto è stato aggiunto con successo!"
|
success_product_edited = "✅ Il prodotto è stato aggiunto/modificato con successo!"
|
||||||
|
|
||||||
# Success: product has been added to the database
|
|
||||||
success_product_edited = "✅ Il prodotto è stato modificato con successo!"
|
|
||||||
|
|
||||||
# Error: message received not in a private chat
|
# Error: message received not in a private chat
|
||||||
error_nonprivate_chat = "⚠️ Questo bot funziona solo in chat private."
|
error_nonprivate_chat = "⚠️ Questo bot funziona solo in chat private."
|
||||||
|
|
|
@ -374,7 +374,7 @@ class ChatWorker(threading.Thread):
|
||||||
# Otherwise, set the fee to 0 to ensure no accidental discounts are applied
|
# Otherwise, set the fee to 0 to ensure no accidental discounts are applied
|
||||||
total_fee = 0
|
total_fee = 0
|
||||||
# Create the invoice keyboard
|
# 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")]])
|
[telegram.InlineKeyboardButton(strings.menu_cancel, callback_data="cmd_cancel")]])
|
||||||
# The amount is valid, send the invoice
|
# The amount is valid, send the invoice
|
||||||
self.bot.send_invoice(self.chat.id,
|
self.bot.send_invoice(self.chat.id,
|
||||||
|
@ -504,7 +504,7 @@ class ChatWorker(threading.Thread):
|
||||||
# Wait for an answer
|
# Wait for an answer
|
||||||
description = self.__wait_for_regex(r"(.*)", cancellable=bool(product))
|
description = self.__wait_for_regex(r"(.*)", cancellable=bool(product))
|
||||||
# Ask for the product price
|
# 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
|
# Display the current name if you're editing an existing product
|
||||||
if 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)
|
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
|
# Commit the session changes
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
# Notify the user
|
# Notify the user
|
||||||
if product:
|
|
||||||
self.bot.send_message(self.chat.id, strings.success_product_edited)
|
self.bot.send_message(self.chat.id, strings.success_product_edited)
|
||||||
else:
|
|
||||||
self.bot.send_message(self.chat.id, strings.success_product_added)
|
|
||||||
|
|
||||||
def __orders_menu(self):
|
def __orders_menu(self):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
Loading…
Reference in a new issue