mirror of
https://github.com/Steffo99/greed.git
synced 2024-11-22 05:54:18 +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)
|
image = Column(LargeBinary)
|
||||||
# Product has been deleted
|
# Product has been deleted
|
||||||
deleted = Column(Boolean, nullable=False)
|
deleted = Column(Boolean, nullable=False)
|
||||||
# Stock quantity, if null product has infinite stock
|
|
||||||
stock = Column(Integer)
|
|
||||||
|
|
||||||
# Extra table parameters
|
# Extra table parameters
|
||||||
__tablename__ = "products"
|
__tablename__ = "products"
|
||||||
|
@ -101,17 +99,12 @@ class Product(TableDeclarativeBase):
|
||||||
if style == "short":
|
if style == "short":
|
||||||
return f"{cart_qty}x {utils.telegram_html_escape(self.name)} - {str(utils.Price(self.price) * cart_qty)}"
|
return f"{cart_qty}x {utils.telegram_html_escape(self.name)} - {str(utils.Price(self.price) * cart_qty)}"
|
||||||
elif style == "full":
|
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:
|
if cart_qty is not None:
|
||||||
cart = strings.in_cart_format_string.format(quantity=cart_qty)
|
cart = strings.in_cart_format_string.format(quantity=cart_qty)
|
||||||
else:
|
else:
|
||||||
cart = ''
|
cart = ''
|
||||||
return strings.product_format_string.format(name=utils.telegram_html_escape(self.name),
|
return strings.product_format_string.format(name=utils.telegram_html_escape(self.name),
|
||||||
description=utils.telegram_html_escape(self.description),
|
description=utils.telegram_html_escape(self.description),
|
||||||
stock=stock,
|
|
||||||
price=str(utils.Price(self.price)),
|
price=str(utils.Price(self.price)),
|
||||||
cart=cart)
|
cart=cart)
|
||||||
else:
|
else:
|
||||||
|
|
11
strings.py
11
strings.py
|
@ -16,7 +16,6 @@ in_cart_format_string = "{quantity} nel carrello"
|
||||||
# Product information
|
# Product information
|
||||||
product_format_string = "<b>{name}</b>\n" \
|
product_format_string = "<b>{name}</b>\n" \
|
||||||
"{description}\n" \
|
"{description}\n" \
|
||||||
"{stock}\n" \
|
|
||||||
"{price}\n" \
|
"{price}\n" \
|
||||||
"<b>{cart}</b>"
|
"<b>{cart}</b>"
|
||||||
|
|
||||||
|
@ -67,9 +66,6 @@ conversation_admin_select_product_to_delete = "❌ Che prodotto vuoi eliminare?"
|
||||||
# Conversation: select a user to edit
|
# Conversation: select a user to edit
|
||||||
conversation_admin_select_user = "Seleziona l'utente a cui vuoi aggiungere o togliere credito."
|
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: click below to pay for the purchase
|
||||||
conversation_cart_actions = "<i>Aggiungi prodotti al carrello scorrendo in su e premendo il pulsante Aggiungi sotto" \
|
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" \
|
" 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 product: current value
|
||||||
edit_current_value = "Il valore attuale è:\n" \
|
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 payment info
|
||||||
payment_cash = "Puoi pagare in contanti alla sede fisica del negozio.\n" \
|
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_order_refunded = "✴️ L'ordine #{order_id} è stato rimborsato con successo."
|
||||||
|
|
||||||
# Success: transaction was created successfully
|
# 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: 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."
|
||||||
|
|
|
@ -584,7 +584,7 @@ class ChatWorker(threading.Thread):
|
||||||
description=strings.payment_invoice_description.format(amount=str(value)),
|
description=strings.payment_invoice_description.format(amount=str(value)),
|
||||||
payload=self.invoice_payload,
|
payload=self.invoice_payload,
|
||||||
provider_token=configloader.config["Credit Card"]["credit_card_token"],
|
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"],
|
currency=configloader.config["Payments"]["currency"],
|
||||||
prices=prices,
|
prices=prices,
|
||||||
need_name=configloader.config["Credit Card"]["name_required"] == "yes",
|
need_name=configloader.config["Credit Card"]["name_required"] == "yes",
|
||||||
|
@ -852,7 +852,6 @@ class ChatWorker(threading.Thread):
|
||||||
self.admin.live_mode = False
|
self.admin.live_mode = False
|
||||||
break
|
break
|
||||||
# Find the order
|
# Find the order
|
||||||
# TODO: debug the regex?
|
|
||||||
order_id = re.search(strings.order_number.replace("{id}", "([0-9]+)"), update.message.text).group(1)
|
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()
|
order = self.session.query(db.Order).filter(db.Order.order_id == order_id).one()
|
||||||
# Check if the order hasn't been already cleared
|
# Check if the order hasn't been already cleared
|
||||||
|
@ -912,7 +911,6 @@ class ChatWorker(threading.Thread):
|
||||||
# Add to the list all the users
|
# Add to the list all the users
|
||||||
for user in users:
|
for user in users:
|
||||||
keyboard_buttons.append([user.identifiable_str()])
|
keyboard_buttons.append([user.identifiable_str()])
|
||||||
# TODO: handle more than 99 users
|
|
||||||
# Create the keyboard
|
# Create the keyboard
|
||||||
keyboard = telegram.ReplyKeyboardMarkup(keyboard_buttons, one_time_keyboard=True)
|
keyboard = telegram.ReplyKeyboardMarkup(keyboard_buttons, one_time_keyboard=True)
|
||||||
# Send the keyboard
|
# Send the keyboard
|
||||||
|
@ -961,7 +959,7 @@ class ChatWorker(threading.Thread):
|
||||||
strings.notification_transaction_created.format(transaction=str(transaction)),
|
strings.notification_transaction_created.format(transaction=str(transaction)),
|
||||||
parse_mode="HTML")
|
parse_mode="HTML")
|
||||||
# Notify the admin of the success
|
# 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):
|
def __help_menu(self):
|
||||||
"""Help menu. Allows the user to ask for assistance, get a guide or see some info about the bot."""
|
"""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