Code Monkey home page Code Monkey logo

telminal's Introduction

telminal

A Terminal in Telegram!

Telegram is a lovely messenger and has so many features that we can manage our Linux server with those features.

What is this?

Telminal is a Python package that helps you have your own server assistant Telegram bot. You can use Telminal as a terminal or to download & upload files.

Telminal features

  • HTML and image output
  • Process state info
  • Interactive command support
  • Download from server
  • Upload to server
  • Multi user
  • Tasks

Getting Started

Prerequisites

You must have a telegram developer API and a bot token
API ID API hash
Bot token
Very fast and easy, you can have those. Just follow these two official links.

Try in colab (bypass single process limitation 🌚)

Open In Colab

Installation

sudo apt-get install python3.9 python3.9-dev python3.9-venv
python3.9 -m venv venv
source ./venv/bin/activate
pip install telminal
telminal

Image output requirements

sudo apt-get install chromium-chromedriver
sudo apt install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget

Setup

setup.mp4

Run telminal command after installation finished. Telminal needs those Telegram tokens for the first run.
Also, you can create a config.json file inside the package directory in this format:

{
    "api_id": 1234,
    "api_hash": "abcs",
    "token": "efgh",
    "admins": [8888, 9999]
}

⚠️ First admin can manage other admins, so order of admins list matter.
In this sample config 8888 must be your Telegram user ID.

Interactive Mode

interactive-mode.mp4

You can activate this mode for the last running process by sending /interactive_mode or by clicking on the Interactive mode button of each process.
In interactive mode, you are talking to the process and each message means an input for that process.
Also, a two characters message that starts with ^ has its meaning and behave like a control command so ^c means CTRL + C.
To return to normal mode and create a new process just use /normal_mode or Exit interactive mode button.

Optional image output

text-version.mp4

Image creation for process result is optimized and will be okay on a server with minimum resources.
However, creating an image on the server is an expensive process. so if you want to run multiple commands at once or have a process that does not require image output, I strongly recommend using the text version by sending \image_off command.

Download file from server

download-from-server.mp4

You can save any file (up to 2GB) of your server on telegram.
There are two ways to do this :

  • Inline query
  • !get command

Inline query just works for the current directory and runs a ls -la | grep <your_query> in the background.
With !get command you can specify the path of a file manually.
Also, you have a nice progress bar when you are downloading or uploading a heavy file.😎

Upload file to server

upload-to-server.mp4

Upload a file on your server just by sending it to Telminal chat.
that file can be in telegram or on your hard disk.

Multi admin in group

multi-admin-multi-chat.mp4

Fortunately, all features can be used in a group too. by default, Telminal only responds to your commands.
!trust and !untrust are two commands that manage user permission.
just reply to one of the user's messages with these commands.

Tasks

tasks.mp4

At this moment, there is only one type of task.
A watcher task downloads a file periodically. write your first watcher in the following format:

!watch <number><s,m,h> <file_path>

Some real examples :

1️⃣ get telminal.log every 50 seconds 👉 !watch 50s telminal.log

2️⃣ get temp.png every 5 minutes 👉 !watch 5m home/temp.png

3️⃣ get sql.dump every 24 hours 👉 !watch 24h /backups/sql.dump


Finally set Telminal commands in Botfather using this text.

image_off - Just text output
image_on - Text and image output
tasks - List of active tasks
interacive_mode - Interact with last process
normal_mode - Process creation mode

Thanks

pexpect
Telethon
xterm.js
puppeteer

telminal's People

Contributors

fristhon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

telminal's Issues

pwsh does not work properly.

I installed the latest powershell 7.3.x and tried using it in telminal, but it keeps printing something weird and also doesn't interact properly, any solutions here?

step:

  • Install pwsh
  • Enter pwsh in telminal and send
  • I get continuous confusing output, and I can't use interactive mode normally:
Stop.Ix��p������������
>> 0��perShell_profile.unml console is readinStop.InformatipStop:PowershellinStop.Ix��p������ux3���perShell_profile.unml console is readinStop.InformatipStop:PowershellinStop.Ix��p�������x3H�|erShell_profile.unml console is readinStop.InformatipStop:PowershellinStop.Ix��p�����b"k��nv3�nv3p��perShell_profile.unml console is readinStop.InformatipStop:PowershellinStop.Ix��p�����h�x3��������-V��perShell_profile.unml console is readinStop.InformatipStop:PowershellinStop.Ix��p�������a���perShell_profile.unml console is readinStop.InformatipStop:PowershellinStop.Ix��p�������perShell_profile.unml console is readinStop.InformatipStop:PowershellinStop.Ix��p������U�����-V��M������perShell_profile.unml console is readinStop.InformatipStop:PowershellinStop.Ix��p�����Ds��>|/��perShell_profile.unml console is readinStop.InformatipStop:PowershellinStop.Ix��p�����nformatipStop:PowershellinStop.Ix��p�������>�|�o��^CPS /home/azureuser> 
                                ^CPS /home/azureuser>

image

Image on

Image_on not working
When i send image_on it's not working, image not coming only test message coming.

Setup telminal

Hi, after i run the command and type my token it show this error. May I know how to fix it?

image

When the text is too long, replace it with a txt file

Sometimes the output of certain commands is too long, which can cause text to be truncated in the message. Such as node -h.

As a solution, I think a txt file can be returned instead of the message when the text is too long.🤔

Cannot use Conda Env

I haven't figured out a way to activate Conda env's. Any advice is appreciated.

Not running Inside Docker Container

Dockerfile

FROM python:latest
ENV PYTHONUNBUFFERED 1
WORKDIR /app
RUN chmod +x /app
RUN sh dependency.sh
RUN pip3 install telminal
COPY config.json /usr/local/lib/python3.10/site-packages/telminal/config.json
CMD ["telminal"]`

OUTPUT:
Starting process with command telminal
State changed from starting to up
Stopping all processes with SIGTERM

loop the process again and again

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.