Key Improvements:
Error Handling:
Used try-except blocks to catch errors from subprocesses and file operations, logging issues.
Thread Safety:
Introduced queue.Queue for thread-safe operations when handling ping results.
Subprocess Optimizations:
Used subprocess.run() for cleaner, more modern handling of subprocesses.
Avoided shell=True for security reasons unless absolutely necessary.
Service Management:
Improved service status checking by using systemctl is-active and using exit statuses for reliability.
User Authorization:
Checked user authorization in relevant commands like /restart, /reboot, and /ping.
Logging:
Introduced logging for all major operations to track activity and errors.
Polling Timeout:
Added timeouts and error handling to prevent the bot from hanging during long polling.
This updoot is bring more security, robustness, and scalability, ready to handle various edge cases that might occur in our system monitoring.
Signed-off-by: hax <hax@lainlounge.xyz>