From 37bf30cbc064ae4ed174ec3570958572f87c563a Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sat, 18 Oct 2025 09:05:17 -0700 Subject: [PATCH] enhance --- modules/survey.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/modules/survey.py b/modules/survey.py index 27b4b0a..da4372b 100644 --- a/modules/survey.py +++ b/modules/survey.py @@ -49,20 +49,24 @@ class SurveyModule: logger.error(f"Survey: Error loading surveys: {e}") def start_survey(self, user_id, survey_name='example', location=None): - """Begin a new survey session for a user.""" - if not survey_name: - survey_name = 'example' - if survey_name not in allowedSurveys: - return f"error: survey '{survey_name}' is not allowed." - self.responses[user_id] = { - 'survey_name': survey_name, - 'current_question': 0, - 'answers': [], - 'location': location if surveyRecordLocation and location is not None else 'N/A' - } - msg = f"'{survey_name}'📝survey\nSend answer' or 'end'\n" - msg += self.show_question(user_id) - return msg + try: + """Begin a new survey session for a user.""" + if not survey_name: + survey_name = 'example' + if survey_name not in allowedSurveys: + return f"error: survey '{survey_name}' is not allowed." + self.responses[user_id] = { + 'survey_name': survey_name, + 'current_question': 0, + 'answers': [], + 'location': location if surveyRecordLocation and location is not None else 'N/A' + } + msg = f"'{survey_name}'📝survey\nSend answer' or 'end'\n" + msg += self.show_question(user_id) + return msg + except Exception as e: + logger.error(f"Error starting survey for user {user_id}: {e}") + return "An error occurred while starting the survey. Please try again later." def show_question(self, user_id): """Show the current question for the user, or end the survey."""