67 lines
3.5 KiB
Python
67 lines
3.5 KiB
Python
# cmd_common/common_commands.py
|
|
import random
|
|
import time
|
|
|
|
def generate_howl_message(username: str) -> str:
|
|
"""
|
|
Return a random howl message (0-100).
|
|
- If 0%: a fail message.
|
|
- If 100%: a perfect success.
|
|
- Otherwise: normal message with the random %.
|
|
"""
|
|
howl_percentage = random.randint(0, 100)
|
|
|
|
if howl_percentage == 0:
|
|
return f"Uh oh, {username} failed with a miserable 0% howl ..."
|
|
elif howl_percentage == 100:
|
|
return f"Wow, {username} performed a perfect 100% howl!"
|
|
else:
|
|
return f"{username} howled at {howl_percentage}%!"
|
|
|
|
def ping():
|
|
"""
|
|
Returns a string, confirming the bot is online.
|
|
"""
|
|
from modules.utility import format_uptime
|
|
from bots import bot_start_time # where you stored the start timestamp
|
|
|
|
current_time = time.time()
|
|
elapsed = current_time - bot_start_time
|
|
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:
|
|
"""
|
|
Returns a greeting string for the given user displayname on a given platform.
|
|
"""
|
|
return f"Hello {target_display_name}, welcome to {platform_name}!" |