1
Fork 0
mirror of https://github.com/Steffo99/greed.git synced 2024-11-24 14:54:18 +00:00

Remove access to missing worker.loc

This commit is contained in:
Steffo 2020-09-09 18:24:18 +02:00
parent 3bcd409056
commit 22adafea59
3 changed files with 17 additions and 1 deletions

10
core.py
View file

@ -154,13 +154,21 @@ def main():
# Otherwise, forward the update to the corresponding worker
receiving_worker = chat_workers.get(update.message.chat.id)
# Ensure a worker exists for the chat and is alive
if receiving_worker is None or not receiving_worker.is_ready():
if receiving_worker is None:
log.debug(f"Received a message in a chat without worker: {update.message.chat.id}")
# Suggest that the user restarts the chat with /start
bot.send_message(update.message.chat.id, default_loc.get("error_no_worker_for_chat"),
reply_markup=telegram.ReplyKeyboardRemove())
# Skip the update
continue
# If the worker is not ready...
if not receiving_worker.is_ready():
log.debug(f"Received a message in a chat where the worker wasn't ready yet: {update.message.chat.id}")
# Suggest that the user restarts the chat with /start
bot.send_message(update.message.chat.id, default_loc.get("error_worker_not_ready"),
reply_markup=telegram.ReplyKeyboardRemove())
# Skip the update
continue
# If the message contains the "Cancel" string defined in the strings file...
if update.message.text == receiving_worker.loc.get("menu_cancel"):
log.debug(f"Forwarding CancelSignal to {receiving_worker}")

View file

@ -395,6 +395,10 @@ error_nonprivate_chat = "⚠️ This bot only works in private chats."
error_no_worker_for_chat = "⚠️ The conversation with the bot was interrupted.\n" \
"To restart it, send the /start command to the bot."
# Error: a message was sent in a chat, but the worker for that chat is not ready.
error_worker_not_ready = "🕒 The conversation with the bot is currently starting.\n" \
"Please, wait a few moments before sending more commands!"
# Error: add funds amount over max
error_payment_amount_over_max = "⚠️ The maximum amount that can be added in a single transaction is {max_amount}."

View file

@ -397,6 +397,10 @@ error_nonprivate_chat = "⚠️ Questo bot funziona solo in chat private."
error_no_worker_for_chat = "⚠️ La conversazione con il bot è interrotta.\n" \
"Per riavviarla, manda il comando /start al bot."
# Error: a message was sent in a chat, but the worker for that chat is not ready.
error_worker_not_ready = "🕒 La conversazione con il bot è in fase di avvio.\n" \
"Per piacere, attendi un attimo prima di inviare altri comandi!"
# Error: add funds amount over max
error_payment_amount_over_max = "⚠️ Il massimo di fondi che possono essere aggiunti in una singola transazione è " \
"{max_amount}."