lexlink / Screen-Watcher-Telegram-Bot-

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

# Screen Manager Telegram Bot

This bot helps you manage your screen sessions in Linux. You can use it to list your screens, run scripts in a screen session, and check the status of your screens.


If one of the screens fail , telegram bot informs you. Right from the bot menu - you can restart the script.



#How to use


To use the bot, first send it the /start command. This will start the bot and give you a list of available commands.


To list your screens, send the /list command. This will show you a list of all your screens, including their names and status.


To run a script in a screen session, send the /run command followed by the name of the script. The bot will create a new screen session and run the script in it.


To check the status of a screen, send the /status command followed by the ID of the screen. The bot will return the status of the screen, such as whether it is attached or detached.


#Code Explanation

The provided Python script does the following:


Imports the necessary module subprocess to interact with the command-line.

Defines a command to list the screens and retrieve their names and status.

Defines a function get_screen_data() to extract screen information from the command output.

Executes the command using subprocess.check_output() and captures the output.

Processes the output to extract relevant information about each screen, including its ID, name, and status.

Returns a list of dictionaries, each representing a detached screen's information.


 

/list

This is the list of screens:

Screen ID: 87888, Name: "NAME OF THE SCREEN", Status: Detached

Screen ID: 44215, Name: "NAME OF THE SCREEN", Status: Detached

Screen ID: 44204, Name: "NAME OF THE SCREEN", Status: Detached

Screen ID: 44182, Name: "NAME OF THE SCREEN", Status: Detached

Screen ID: 1333, Name: "NAME OF THE SCREEN", Status: Detached

About


Languages

Language:Python 100.0%