mirror of
https://github.com/Steffo99/greed.git
synced 2024-11-21 21:44:19 +00:00
UNFINISHED
This commit is contained in:
parent
d3a89f3215
commit
17b4be529d
3 changed files with 7 additions and 17 deletions
|
@ -85,8 +85,6 @@ class Product(TableDeclarativeBase):
|
|||
image = Column(LargeBinary)
|
||||
# Product has been deleted
|
||||
deleted = Column(Boolean, nullable=False)
|
||||
# Stock quantity, if null product has infinite stock
|
||||
stock = Column(Integer)
|
||||
|
||||
# Extra table parameters
|
||||
__tablename__ = "products"
|
||||
|
@ -101,17 +99,12 @@ class Product(TableDeclarativeBase):
|
|||
if style == "short":
|
||||
return f"{cart_qty}x {utils.telegram_html_escape(self.name)} - {str(utils.Price(self.price) * cart_qty)}"
|
||||
elif style == "full":
|
||||
if self.stock is not None:
|
||||
stock = strings.in_stock_format_string.format(quantity=self.stock)
|
||||
else:
|
||||
stock = ''
|
||||
if cart_qty is not None:
|
||||
cart = strings.in_cart_format_string.format(quantity=cart_qty)
|
||||
else:
|
||||
cart = ''
|
||||
return strings.product_format_string.format(name=utils.telegram_html_escape(self.name),
|
||||
description=utils.telegram_html_escape(self.description),
|
||||
stock=stock,
|
||||
price=str(utils.Price(self.price)),
|
||||
cart=cart)
|
||||
else:
|
||||
|
|
11
strings.py
11
strings.py
|
@ -16,7 +16,6 @@ in_cart_format_string = "{quantity} nel carrello"
|
|||
# Product information
|
||||
product_format_string = "<b>{name}</b>\n" \
|
||||
"{description}\n" \
|
||||
"{stock}\n" \
|
||||
"{price}\n" \
|
||||
"<b>{cart}</b>"
|
||||
|
||||
|
@ -67,9 +66,6 @@ conversation_admin_select_product_to_delete = "❌ Che prodotto vuoi eliminare?"
|
|||
# Conversation: select a user to edit
|
||||
conversation_admin_select_user = "Seleziona l'utente a cui vuoi aggiungere o togliere credito."
|
||||
|
||||
# Conversation: add extra notes to the order
|
||||
conversation_extra_notes = "Che messaggio vuoi lasciare insieme al tuo ordine?"
|
||||
|
||||
# Conversation: click below to pay for the purchase
|
||||
conversation_cart_actions = "<i>Aggiungi prodotti al carrello scorrendo in su e premendo il pulsante Aggiungi sotto" \
|
||||
" i prodotti che desideri acquistare. Quando avrai terminato, torna a questo messaggio e" \
|
||||
|
@ -227,7 +223,9 @@ downloading_image = "Sto scaricando la tua foto!\n" \
|
|||
|
||||
# Edit product: current value
|
||||
edit_current_value = "Il valore attuale è:\n" \
|
||||
"<pre>{value}</pre>"
|
||||
"<pre>{value}</pre>\n" \
|
||||
"\n" \
|
||||
"<i>Premi il tasto Salta sotto questo messaggio per mantenere lo stesso valore.</i>"
|
||||
|
||||
# Payment: cash payment info
|
||||
payment_cash = "Puoi pagare in contanti alla sede fisica del negozio.\n" \
|
||||
|
@ -308,7 +306,8 @@ success_order_completed = "✅ Hai segnato l'ordine #{order_id} come completato.
|
|||
success_order_refunded = "✴️ L'ordine #{order_id} è stato rimborsato con successo."
|
||||
|
||||
# Success: transaction was created successfully
|
||||
success_transaction_created = "✅ La transazione è stata creata con successo!"
|
||||
success_transaction_created = "✅ La transazione è stata creata con successo!\n" \
|
||||
"{transaction}"
|
||||
|
||||
# Error: message received not in a private chat
|
||||
error_nonprivate_chat = "⚠️ Questo bot funziona solo in chat private."
|
||||
|
|
|
@ -584,7 +584,7 @@ class ChatWorker(threading.Thread):
|
|||
description=strings.payment_invoice_description.format(amount=str(value)),
|
||||
payload=self.invoice_payload,
|
||||
provider_token=configloader.config["Credit Card"]["credit_card_token"],
|
||||
start_parameter="tempdeeplink", # TODO: no idea on how deeplinks should work
|
||||
start_parameter="tempdeeplink",
|
||||
currency=configloader.config["Payments"]["currency"],
|
||||
prices=prices,
|
||||
need_name=configloader.config["Credit Card"]["name_required"] == "yes",
|
||||
|
@ -852,7 +852,6 @@ class ChatWorker(threading.Thread):
|
|||
self.admin.live_mode = False
|
||||
break
|
||||
# Find the order
|
||||
# TODO: debug the regex?
|
||||
order_id = re.search(strings.order_number.replace("{id}", "([0-9]+)"), update.message.text).group(1)
|
||||
order = self.session.query(db.Order).filter(db.Order.order_id == order_id).one()
|
||||
# Check if the order hasn't been already cleared
|
||||
|
@ -912,7 +911,6 @@ class ChatWorker(threading.Thread):
|
|||
# Add to the list all the users
|
||||
for user in users:
|
||||
keyboard_buttons.append([user.identifiable_str()])
|
||||
# TODO: handle more than 99 users
|
||||
# Create the keyboard
|
||||
keyboard = telegram.ReplyKeyboardMarkup(keyboard_buttons, one_time_keyboard=True)
|
||||
# Send the keyboard
|
||||
|
@ -961,7 +959,7 @@ class ChatWorker(threading.Thread):
|
|||
strings.notification_transaction_created.format(transaction=str(transaction)),
|
||||
parse_mode="HTML")
|
||||
# Notify the admin of the success
|
||||
self.bot.send_message(self.chat.id, strings.success_transaction_created)
|
||||
self.bot.send_message(self.chat.id, strings.success_transaction_created.format(transaction=str(transaction)))
|
||||
|
||||
def __help_menu(self):
|
||||
"""Help menu. Allows the user to ask for assistance, get a guide or see some info about the bot."""
|
||||
|
|
Loading…
Reference in a new issue