https://github.com/alfiankan/teleterm
Telegram Bot Exec Terminal Command
https://github.com/alfiankan/teleterm
bot go golang ssh telegram telegram-bot terminal
Last synced: about 1 month ago
JSON representation
Telegram Bot Exec Terminal Command
- Host: GitHub
- URL: https://github.com/alfiankan/teleterm
- Owner: alfiankan
- License: mit
- Created: 2020-12-31T22:34:18.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-07-02T16:35:56.000Z (almost 2 years ago)
- Last Synced: 2024-07-31T20:37:10.156Z (9 months ago)
- Topics: bot, go, golang, ssh, telegram, telegram-bot, terminal
- Language: Go
- Homepage:
- Size: 23.7 MB
- Stars: 34
- Watchers: 2
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-go - teleterm - Telegram Bot Exec Terminal Command. (Bot Building)
- fucking-awesome-go - teleterm - Telegram Bot Exec Terminal Command. (Bot Building)
- awesome-go - teleterm - Telegram Bot Exec Terminal Command. (Bot Building)
- awesome-go - teleterm - Telegram Bot Exec Terminal Command. (Bot Building)
- awesome-go-extra - teleterm - 12-31T22:34:18Z|2022-07-12T02:46:52Z| (Bot Building / Free e-books)
- awesome-go-with-stars - teleterm - Telegram Bot Exec Terminal Command. (Bot Building)
- awesome-go-cn - teleterm
- awesome-go-plus - teleterm - Telegram Bot Exec Terminal Command.  (Bot Building)
- awesome-go-plus - teleterm - Telegram Bot Exec Terminal Command.  (Bot Building)
README
# Teleterm
Telegram Bot Exec Terminal Command[](https://codecov.io/gh/alfiankan/teleterm)
[](https://github.com/avelino/awesome-go)
[](https://pkg.go.dev/github.com/alfiankan/teleterm/v2)
[](https://goreportcard.com/badge/github.com/alfiankan/teleterm)
## Use Case
- Running command on IoT Device through telegram bot
- Transfering Files through telegram bot## How To Install
1. Prebuilt Binary
you can download prebuild binary depends on your os and arch, available prebuilts here:https://github.com/alfiankan/teleterm/releases/tag/v2.1.0
Once the binary is downloaded, you can move the binary to /usr/local/bin2. Build From Source
If your arch os is not listed in the prebuilt binary you can build from source.
Required :
- Go ^1.18
- gccHow to build :
- clone `git clone https://github.com/alfiankan/teleterm`
- build `go build -o teleterm-bin ./cmd...`## How To Run :
Required :
- Telegram bot tokens, to get tokens please refer to [Telegram Docs](https://core.telegram.org/bots#6-botfather)1. Setting Up Config
To setup fresh teleterm run
```bash
teleterm fresh
```
teleterm will create folder on your home folder with name `.teleterm` contains :
- config.yaml
config yaml hold teleterm config :| Key |Value |
| ------------- |-------------|
| telegram_token | telegram token from bot father |
| shell_executor | `/bin/bash` or `/bin/sh` .etc default is `/bin/bash`|example config.yaml
```yaml
teleterm:
telegram_token: "my_tele_token"
shell_executor: "/bin/bash"
```2. Run teleterm
To run teleterm simply run `teleterm` and log info will displayed.

## Available Bot Command
| Command |Desc |Example |
| ------------- |:-------------|:-------------|
|/refresh |Refresh the bot system | /refresh |
| /run ``| executing command | /run ping -c 5 8.8.8.8 |
| /getfile ``| transfer donwload file from bot server | /getfile /home/raspi/myfile.txt |
|/addbutton `!!`| add button shortcut | /addbutton ping!!ping -c 5 8.8.8.8 |
|/deletebutton ``|delete button shortcut | /deletebutton ping |## Run Command
To execute commands from telegram just send a message using the following format :
```bash
/run
```
for example :
```bash
/run ping -c 5 8.8.8.8
```
output replied by telegram bot :
## Add Button Shortcut
To execute commands from the telegram button, you need to add a button, just send a message using the following format :
```bash
/addbutton !!
```
for example :
```bash
/addbutton ping!!ping -c 5 8.8.8.8
```
output replied by telegram bot :
a new button will appear :

## Shortcut Button
To run a command using a shortcut just click the telegram button the bot will find the exec command from the database.## Delete Button Shortcut
To remove a shortcut simply send a message using the following format:
```bash
/deletebutton
```
for example :
```bash
/deletebutton ping
```
output replied by telegram bot :
then updated buttons will appear.
## Uploading File
To upload a file just send the document on telegram :
By default it will upload in cwd path if you don't add target path on file mention.
output replied by telegram bot :

## Download file
To download the file simply send a message using the following format :
```bash
/getfile
```Filepath is the filepath where teleterm runs
for example :
```bash
/getfile /home/raspi/hello.txt
```
output replied by telegram bot :