mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 03:40:11 +01:00
refactor(bot): bot utilities into separate modules
Moved logging, signal handling, and uptime calculation logic from bot.py into dedicated utils modules for better organization and reusability. Updated imports and usage in bot.py and utils/__init__.py accordingly.
This commit is contained in:
18
utils/time.py
Normal file
18
utils/time.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import time
|
||||
|
||||
|
||||
def get_uptime(start_time: float) -> str:
|
||||
uptime_seconds = int(time.time() - start_time)
|
||||
days = uptime_seconds // 86400
|
||||
hours = (uptime_seconds % 86400) // 3600
|
||||
minutes = (uptime_seconds % 3600) // 60
|
||||
seconds = uptime_seconds % 60
|
||||
|
||||
if days > 0:
|
||||
return f"{days}d {hours}h {minutes}m {seconds}s"
|
||||
elif hours > 0:
|
||||
return f"{hours}h {minutes}m {seconds}s"
|
||||
elif minutes > 0:
|
||||
return f"{minutes}m {seconds}s"
|
||||
else:
|
||||
return f"{seconds}s"
|
||||
Reference in New Issue
Block a user