diff --git a/cmd_common/common_commands.py b/cmd_common/common_commands.py index b954e99..87c52dc 100644 --- a/cmd_common/common_commands.py +++ b/cmd_common/common_commands.py @@ -27,9 +27,38 @@ def ping(): current_time = time.time() elapsed = current_time - bot_start_time - uptime_str = format_uptime(elapsed) - response = f"Pong! I've been awake for {uptime_str}. Send coffee!" - return f"{response}" + uptime_str, uptime_s = format_uptime(elapsed) + # Define thresholds in ascending order + # (threshold_in_seconds, message) + # The message is a short "desperation" or "awake" text. + time_ranges = [ + (3600, f"I've been awake for {uptime_str}. I just woke up, feeling great!"), # < 1 hour + (10800, f"I've been awake for {uptime_str}. I'm still fairly fresh!"), # 3 hours + (21600, f"I've been awake for {uptime_str}. I'm starting to get a bit weary..."), # 6 hours + (43200, f"I've been awake for {uptime_str}. 12 hours?! Might be time for coffee."), # 12 hours + (86400, f"I've been awake for {uptime_str}. A whole day without sleep... I'm okay?"), # 1 day + (172800, f"I've been awake for {uptime_str}. Two days... I'd love a nap."), # 2 days + (259200, f"I've been awake for {uptime_str}. Three days. Is sleep optional now?"), # 3 days + (345600, f"I've been awake for {uptime_str}. Four days... I'm running on fumes."), # 4 days + (432000, f"I've been awake for {uptime_str}. Five days. Please send more coffee."), # 5 days + (518400, f"I've been awake for {uptime_str}. Six days. I've forgotten what dreams are."), # 6 days + (604800, f"I've been awake for {uptime_str}. One week. I'm turning into a zombie."), # 7 days + (1209600, f"I've been awake for {uptime_str}. Two weeks. Are you sure I can't rest?"), # 14 days + (2592000, f"I've been awake for {uptime_str}. A month! The nightmares never end."), # 30 days + (7776000, f"I've been awake for {uptime_str}. Three months. I'm mostly coffee now."), # 90 days + (15552000,f"I've been awake for {uptime_str}. Six months. This is insane..."), # 180 days + (23328000,f"I've been awake for {uptime_str}. Nine months. I might be unstoppable."), # 270 days + (31536000,f"I've been awake for {uptime_str}. A year?! I'm a legend of insomnia..."), # 365 days + ] + + # We'll iterate from smallest to largest threshold + for threshold, msg in time_ranges: + if uptime_s < threshold: + return msg + + # If none matched, it means uptime_s >= 31536000 (1 year+) + return f"I've been awake for {uptime_str}. Over a year awake... I'm beyond mortal limits!" + def greet(target_display_name: str, platform_name: str) -> str: """ diff --git a/modules/utility.py b/modules/utility.py index bec6ebd..eab6097 100644 --- a/modules/utility.py +++ b/modules/utility.py @@ -21,14 +21,14 @@ def format_uptime(seconds: float) -> str: # Build a short string, only listing the largest units # If you want more detail, you can keep going if years > 0: - return f"{years} year(s), {months} month(s)" + return [f"{years} year(s), {months} month(s)", seconds] elif months > 0: - return f"{months} month(s), {days} day(s)" + return [f"{months} month(s), {days} day(s)", seconds] elif days > 0: - return f"{days} day(s), {hours} hour(s)" + return [f"{days} day(s), {hours} hour(s)", seconds] elif hours > 0: - return f"{hours} hour(s), {minutes} minute(s)" + return [f"{hours} hour(s), {minutes} minute(s)", seconds] elif minutes > 0: - return f"{minutes} minute(s)" + return [f"{minutes} minute(s)", seconds] else: - return f"{seconds} second(s)" \ No newline at end of file + return [f"{seconds} second(s)", seconds] \ No newline at end of file