diff --git a/src/handlers/record_handlers.py b/src/handlers/record_handlers.py index e6ae59f..be48ad1 100644 --- a/src/handlers/record_handlers.py +++ b/src/handlers/record_handlers.py @@ -7,7 +7,7 @@ import src.repository.record_repository as record_repository from src.handlers.graphing import handle_graph_specification from src.handlers.metrics_handlers import prompt_user_for_metric -from src.handlers.util import send +from src.handlers.util import send, handle_no_known_state from src.model.metric import Metric from src.model.record import TempRecord from src.repository import user_repository @@ -103,17 +103,6 @@ async def button(update: Update, _) -> None: await handle_no_known_state(update) -async def handle_no_known_state(update: Update) -> None: - """ - Handles the case where the user is not in a known state. - This can happen if the user has not started recording or graphing, or if the state has expired. - :param update: The update object. - """ - no_state_message = """It doesn't appear like you're currently recording mood or graphing. - Press /record to create a new record, /graph to visualise your mood progress.""" - await send(update, text=no_state_message) - - async def handle_record_entry(update: Update) -> None: """ When a button update is received while the user is recording a record, this function is called. @@ -130,7 +119,6 @@ async def handle_record_entry(update: Update) -> None: # retrieve query prompt and answer user_id = update.effective_user.id query = update.callback_query - prompt = query.message.text await query.answer() # retrieve current record @@ -198,8 +186,10 @@ async def offset_handler(update: Update, context) -> None: :param context: holds the arguments passed to the command :return: """ - incorrect_state_message = """You can only use /offset while recording a record. - Press /record to create a new record.""" + incorrect_state_message = ( + "You can only use /offset while recording a record. " + "Press /record to create a new record." + ) success_message = "The timestamp of your record has been updated to {}." invalid_args_message = "Please provide an offset in days like this: /offset 1" user_state = APPLICATION_STATE.get(update.effective_user.id) diff --git a/src/handlers/user_handlers.py b/src/handlers/user_handlers.py index 1747057..8b08789 100644 --- a/src/handlers/user_handlers.py +++ b/src/handlers/user_handlers.py @@ -20,9 +20,9 @@ async def create_user(update: Update, _) -> None: [f"- {metric.name.capitalize()}" for metric in load_metrics()] ) introduction_text = ( - "Hi! You can track your mood with me. Simply type /record to get started. By default, " - f"I will track the following metrics: \n " - f"{bullet_point_list}" + "Hi! You can track your mood with me. " + "Simply type /record to get started. By default, " + f"I will track the following metrics:\n {bullet_point_list}" ) # Handle registration @@ -34,3 +34,8 @@ async def create_user(update: Update, _) -> None: # User already exists else: logging.info(f"Received /start, but user {user_id} already exists") + await send( + update, + text="You are already registered! If you want to re-assess your metrics or notifications, " + "type /metrics or /notifications to do so.", + ) diff --git a/src/handlers/util.py b/src/handlers/util.py index e35f35c..bd082ca 100644 --- a/src/handlers/util.py +++ b/src/handlers/util.py @@ -10,3 +10,16 @@ async def send(update: Update, text: str): await update.effective_user.get_bot().send_message( chat_id=update.effective_user.id, text=text ) + + +async def handle_no_known_state(update: Update) -> None: + """ + Handles the case where the user is not in a known state. + This can happen if the user has not started recording or graphing, or if the state has expired. + :param update: The update object. + """ + no_state_message = ( + "It doesn't appear like you're currently recording mood or graphing. " + "Press /record to create a new record, /graph to visualise your mood progress." + ) + await send(update, text=no_state_message) diff --git a/test/test_user_init.py b/test/test_user_init.py index b72e593..2e1166c 100644 --- a/test/test_user_init.py +++ b/test/test_user_init.py @@ -38,6 +38,9 @@ async def test_registration(update): @pytest.mark.asyncio +@pytest.mark.skip( + "I have added a message to the user when they are already registered for clarity" +) async def test_no_double_registration(update): # user does not exist assert user_repository.find_user(1) is None