mirror of
https://github.com/Steffo99/greed.git
synced 2024-11-24 23:04:18 +00:00
Might have fixed something
This commit is contained in:
parent
13ca9c5391
commit
5ae466de13
3 changed files with 20 additions and 11 deletions
2
core.py
2
core.py
|
@ -51,7 +51,7 @@ def main():
|
|||
old_worker = chat_workers.get(update.message.chat.id)
|
||||
# If it exists, gracefully stop the worker
|
||||
if old_worker:
|
||||
old_worker.stop()
|
||||
old_worker.stop("request")
|
||||
# Initialize a new worker for the chat
|
||||
new_worker = worker.ChatWorker(bot, update.message.chat)
|
||||
# Start the worker
|
||||
|
|
14
strings.py
14
strings.py
|
@ -35,7 +35,10 @@ order_format_string = "di {user}\n" \
|
|||
|
||||
# Conversation: the start command was sent and the bot should welcome the user
|
||||
conversation_after_start = "Ciao!\n" \
|
||||
"Benvenuto su greed!"
|
||||
"Benvenuto su greed!\n" \
|
||||
"Quella che vedi qui è la versione Alpha del software.\n" \
|
||||
"Pertanto, funzioni potranno essere aggiunte o rimosse in qualsiasi momento," \
|
||||
" e l'interfaccia utente potrebbe risultare incompleta."
|
||||
|
||||
# Conversation: to send an inline keyboard you need to send a message with it
|
||||
conversation_open_user_menu = "Cosa vorresti fare?\n" \
|
||||
|
@ -91,7 +94,7 @@ menu_order_status = "🛍 Stato ordini"
|
|||
menu_add_credit = "💵 Aggiungi fondi"
|
||||
|
||||
# User menu: bot info
|
||||
menu_bot_info = "ℹ️ Informazioni sul bot"
|
||||
menu_bot_info = "ℹ️ Info sul bot"
|
||||
|
||||
# User menu: cash
|
||||
menu_cash = "💵 In contanti"
|
||||
|
@ -148,7 +151,7 @@ menu_add_to_cart = "➕ Aggiungi"
|
|||
menu_remove_from_cart = "➖ Rimuovi"
|
||||
|
||||
# Menu: help menu
|
||||
menu_help = "❓ Aiuto, assistenza e informazioni"
|
||||
menu_help = "❓ Aiuto e assistenza"
|
||||
|
||||
# Menu: guide
|
||||
menu_guide = "📖 Guida"
|
||||
|
@ -215,7 +218,10 @@ payment_cc_amount = "Quanti fondi vuoi aggiungere al tuo portafoglio?"
|
|||
payment_invoice_title = "Aggiunta di fondi"
|
||||
|
||||
# Payment: add funds invoice description
|
||||
payment_invoice_description = "Pagando questa ricevuta verranno aggiunti {amount} al portafoglio."
|
||||
payment_invoice_description = "Pagando questa ricevuta verranno aggiunti {amount} al portafoglio.\n\n" \
|
||||
"Visto che sei nella versione Alpha del software, puoi effettuare pagamenti con la " \
|
||||
"carta di credito di prova `4242 4242 4242 4242`, con qualsiasi CVV e una data di " \
|
||||
"scadenza valida."
|
||||
|
||||
# Payment: label of the labeled price on the invoice
|
||||
payment_invoice_label = "Ricarica"
|
||||
|
|
15
worker.py
15
worker.py
|
@ -109,11 +109,11 @@ class ChatWorker(threading.Thread):
|
|||
data = self.queue.get(timeout=int(configloader.config["Telegram"]["conversation_timeout"]))
|
||||
except queuem.Empty:
|
||||
# If the conversation times out, gracefully stop the thread
|
||||
self.__graceful_stop()
|
||||
self.__graceful_stop(StopSignal("timeout"))
|
||||
# Check if the data is a stop signal instance
|
||||
if isinstance(data, StopSignal):
|
||||
# Gracefully stop the process
|
||||
self.__graceful_stop()
|
||||
self.__graceful_stop(data)
|
||||
# Return the received update
|
||||
return data
|
||||
|
||||
|
@ -490,7 +490,6 @@ class ChatWorker(threading.Thread):
|
|||
|
||||
def __add_credit_menu(self):
|
||||
"""Add more credit to the account."""
|
||||
# TODO: a loop might be needed here
|
||||
# Create a payment methods keyboard
|
||||
keyboard = list()
|
||||
# Add the supported payment methods to the keyboard
|
||||
|
@ -991,10 +990,14 @@ class ChatWorker(threading.Thread):
|
|||
self.bot.send_message(self.chat.id, strings.contact_shopkeeper.format(shopkeepers=shopkeepers_string))
|
||||
# If the user has selected the Cancel option the function will return immediately
|
||||
|
||||
def __graceful_stop(self):
|
||||
def __graceful_stop(self, stop_trigger: StopSignal):
|
||||
"""Handle the graceful stop of the thread."""
|
||||
# Notify the user that the session has expired and remove the keyboard
|
||||
self.bot.send_message(self.chat.id, strings.conversation_expired, reply_markup=telegram.ReplyKeyboardRemove())
|
||||
# If the session has expired...
|
||||
if stop_trigger.reason == "timeout":
|
||||
# Notify the user that the session has expired and remove the keyboard
|
||||
self.bot.send_message(self.chat.id, strings.conversation_expired, reply_markup=telegram.ReplyKeyboardRemove())
|
||||
# If a restart has been requested...
|
||||
# Do nothing.
|
||||
# Close the database session
|
||||
# End the process
|
||||
sys.exit(0)
|
||||
|
|
Loading…
Reference in a new issue