This program collects system information and file paths from the specified directories and sends them as a document to a specified chat using the Telegram bot API. Here's an overview of how the program works:
-
It imports necessary modules: telebot for interacting with the Telegram bot API, platform for retrieving system information, os for interacting with the operating system, time for timing the execution, psutil for retrieving system resource information, and zipfile for creating a compressed archive.
-
The write_file_paths function is defined to write the file paths of a specified directory to an output file. It traverses the directory recursively and writes each file path to the output file.
-
The program sets up the Telegram bot using the provided TOKEN and CHAT_ID.
-
System information is collected using the platform and psutil modules. Information such as the operating system, processor, Python version, memory usage, CPU usage, and disk space is collected and stored in the info variable.
-
The program initializes variables for storing CPU usage, memory information, and disk usage.
-
The write_file_paths function is called for each drive letter from 'A' to 'Z'. The file paths for each drive are written to the output_file_path file, along with the system information stored in the info variable.
-
The file paths are then compressed into a ZIP archive using the zipfile module and saved as archive_file_path.
-
The output_file_path file is deleted as it is no longer needed.
-
The program sends the compressed archive file as a document to the specified chat using the Telegram bot.
-
The compressed archive file is deleted from the local system.
-
The program exits.
Overall, this program collects system information, retrieves file paths from specified directories, and sends the collected data as a compressed archive file to a Telegram chat using a bot.