{"id":13491760,"url":"https://github.com/msoap/shell2telegram","last_synced_at":"2025-04-04T23:07:50.173Z","repository":{"id":144202357,"uuid":"43320039","full_name":"msoap/shell2telegram","owner":"msoap","description":"Telegram bot constructor from command-line","archived":false,"fork":false,"pushed_at":"2024-09-30T21:05:10.000Z","size":233,"stargazers_count":154,"open_issues_count":0,"forks_count":22,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-28T22:12:24.261Z","etag":null,"topics":["docker","golang","server","shell","telegram","telegram-bots"],"latest_commit_sha":null,"homepage":"https://telegram.me/shell2telegram","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msoap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-28T18:48:45.000Z","updated_at":"2025-03-04T14:42:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"45feb382-229d-4691-a6c2-052bef69b19b","html_url":"https://github.com/msoap/shell2telegram","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msoap%2Fshell2telegram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msoap%2Fshell2telegram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msoap%2Fshell2telegram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msoap%2Fshell2telegram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msoap","download_url":"https://codeload.github.com/msoap/shell2telegram/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247261603,"owners_count":20910108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","golang","server","shell","telegram","telegram-bots"],"created_at":"2024-07-31T19:00:59.947Z","updated_at":"2025-04-04T23:07:50.158Z","avatar_url":"https://github.com/msoap.png","language":"Go","funding_links":[],"categories":["Go","Tools","工具"],"sub_categories":["Bot Libs","机器人类库"],"readme":"\u003cimg src=\"https://raw.githubusercontent.com/msoap/shell2telegram/misc/img/shell2telegram_icon.png\" width=\"32\" height=\"32\"\u003e shell2telegram\n-----------------------------------------------------------------------------------------------------------------------------------------\n\n[![Go build status](https://github.com/msoap/shell2telegram/actions/workflows/go.yml/badge.svg)](https://github.com/msoap/shell2telegram/actions/workflows/go.yml)\n[![Coverage Status](https://coveralls.io/repos/github/msoap/shell2telegram/badge.svg?branch=master)](https://coveralls.io/github/msoap/shell2telegram?branch=master)\n[![Docker Pulls](https://img.shields.io/docker/pulls/msoap/shell2telegram.svg?maxAge=3600)](https://hub.docker.com/r/msoap/shell2telegram/)\n[![Homebrew formula exists](https://img.shields.io/badge/homebrew-🍺-d7af72.svg)](https://github.com/msoap/shell2telegram#install)\n[![Report Card](https://goreportcard.com/badge/github.com/msoap/shell2telegram)](https://goreportcard.com/report/github.com/msoap/shell2telegram)\n\nCreate Telegram bot from command-line\n\nInstall\n-------\n\nMacOS:\n\n    brew tap msoap/tools\n    brew install shell2telegram\n    # update:\n    brew upgrade shell2telegram\n\nOr download binaries from: [releases](https://github.com/msoap/shell2telegram/releases) (OS X/Linux/Windows/RaspberryPi)\n\nOr build from source:\n\n    # set $GOPATH if needed\n    go install github.com/msoap/shell2telegram@latest\n    ln -s $GOPATH/bin/shell2telegram ~/bin/shell2telegram # or add $GOPATH/bin to $PATH\n\nOr build image and run with Docker.\nExample of `test-bot.Dockerfile` for bot who say current date:\n\n    FROM msoap/shell2telegram\n    # may be install some alpine packages:\n    # RUN apk add --no-cache ...\n    ENV TB_TOKEN=*******\n    CMD [\"/date\", \"date\"]\n\nAnd build and run:\n\n    docker build -f test-bot.Dockerfile -t test-bot .\n    docker run --rm test-bot\n    # or run with set token from command line\n    docker run -e TB_TOKEN=******* --rm test-bot\n\nUsing snap (Ubuntu or any Linux distribution with snap):\n\n    # install stable version:\n    sudo snap install shell2telegram\n    \n    # install the latest version:\n    sudo snap install --edge shell2telegram\n    \n    # update\n    sudo snap refresh shell2telegram\n\nNotice: the snap-package has its own sandbox with the `/bin`, `/usr/bin` directories which are not equal to system-wide `PATH` directories.\n\nUsage\n-----\n\nGet token from [BotFather bot](https://telegram.me/BotFather), and set TB_TOKEN var in shell\n\n    export TB_TOKEN=*******\n    shell2telegram [options] /chat_command 'shell command' /chat_command2 'shell command2'\n    options:\n        -allow-users=\u003cNAMES\u003e : telegram users who are allowed to chat with the bot (\"user1,user2\")\n        -root-users=\u003cNAMES\u003e  : telegram users, who confirms new users in their private chat (\"user1,user2\")\n        -allow-all           : allow all users (DANGEROUS!)\n        -add-exit            : adding \"/shell2telegram exit\" command for terminate bot (for roots only)\n        -log-commands        : logging all commands\n        -tb-token=\u003cTOKEN\u003e    : setting bot token (or set TB_TOKEN variable)\n        -timeout=N           : setting timeout for bot (default 60 sec)\n        -description=\u003cTITLE\u003e : setting description of bot\n        -bind-addr=\u003cADDRESS\u003e : address to listen incoming webhook requests\n        -webhook=\u003cURL\u003e       : url for registering a webhook\n        -persistent-users    : load/save users from file (default ~/.config/shell2telegram.json)\n        -users-db=\u003cFILENAME\u003e : file for store users\n        -cache=N             : caching command out for N seconds\n        -one-thread          : run each shell command in one thread\n        -public              : bot is public (don't add /auth* commands)\n        -sh-timeout=N        : set timeout for execute shell command (in seconds)\n        -shell=\"shell\"       : shell for execute command, \"\" - without shell (default \"sh\")\n        -version\n        -help\n\nIf not define -allow-users/-root-users options - authorize users via secret code from console or via chat with exists root users.\n\nAll text after /chat_command will be sent to STDIN of shell command.\n\nSpecial chat commands\n---------------------\n\nfor private chats only:\n\n  * `/:plain_text` - get user message without any /command.\n\nTODO:\n\n  * `/:image` - for get image from user. Example: `/:image 'cat \u003e file.jpg; echo ok'`\n  * `/:file`  - for get file from user\n  * `/:location`  - for get geo-location from user\n\nPossible long-running shell processes (for example alarm/timer bot).\n\nAutodetect images (png/jpg/gif/bmp) out from shell command, for example: `/get_image 'cat file.png'`\n\nSetting environment variables for shell commands:\n\n  * S2T_LOGIN - telegram @login (may be empty)\n  * S2T_USERID - telegram user ID\n  * S2T_USERNAME - telegram user name\n  * S2T_CHATID - chat ID\n\nModificators for bot commands\n-----------------------------\n\n  * `:desc` - setting the description of command, `/cmd:desc=\"Command name\" 'shell cmd'`\n  * `:vars` - to create environment variables instead of text output to STDIN, `/cmd:vars=VAR1,VAR2 'echo $VAR1 / $VAR2'`\n  * `:md` - to send message as markdown text, `/cmd:md 'echo \"*bold* and _italic_\"'`\n\nTODO:\n\n  * `/cmd:cron=3600` — periodic exec command, `/cmd:on args` - on, `/cmd:off` - off\n\nPredefined bot commands\n-----------------------\n\n  * `/help` - list available commands\n  * `/auth` - begin authorize new user\n  * `/auth \u003cCODE\u003e` - authorize with code from console or from exists root user\n  * `/authroot` - same for new root user\n  * `/authroot \u003cCODE\u003e` - same for new root user\n\nfor root users only:\n\n  * `/shell2telegram stat` - show users statistics\n  * `/shell2telegram search \u003cquery\u003e` - search users by name/id\n  * `/shell2telegram ban \u003cuser_id|@username\u003e` - ban user\n  * `/shell2telegram exit` - terminate bot (for run with -add-exit)\n  * `/shell2telegram desc \u003cdescription\u003e` - set bot description\n  * `/shell2telegram rm \u003c/command\u003e` - delete command\n  * `/shell2telegram broadcast_to_root \u003cmessage\u003e` - send message to all root users in private chat\n  * `/shell2telegram message_to_user \u003cuser_id|@username\u003e \u003cmessage\u003e` - send message to user in private chat\n  * `/shell2telegram version` - show version\n\nExamples\n--------\n\n    # system information\n    shell2telegram /top:desc=\"System information\" 'top -l 1 | head -10' /date 'date' /ps 'ps aux -m | head -20'\n    \n    # sort any input\n    shell2telegram /:plain_text sort\n    \n    # alarm bot:\n    # /alarm time_in_seconds message\n    shell2telegram /alarm:vars=SLEEP,MSG 'sleep $SLEEP; echo Hello $S2T_USERNAME; echo Alarm: $MSG'\n    \n    # sound volume control via telegram (Mac OS)\n    shell2telegram /get  'osascript -e \"output volume of (get volume settings)\"' \\\n                   /up   'osascript -e \"set volume output volume (($(osascript -e \"output volume of (get volume settings)\")+10))\"' \\\n                   /down 'osascript -e \"set volume output volume (($(osascript -e \"output volume of (get volume settings)\")-10))\"'\n\n    # using with webhook instead of poll\n    shell2telegram -bind-addr=0.0.0.0:8080 -webhook=https://bot.example.com/path/to/bot \\\n                   /date /date\n\n    # command with Markdown formating, calendar in monospace font\n    shell2telegram /cal:md 'echo \"\\`\\`\\`$(ncal)\\`\\`\\`\"'\n\nLinks\n-----\n\n  * [Telegram channel about shell2telegram](https://telegram.me/shell2telegram)\n  * [About Telegram bots](https://core.telegram.org/bots)\n  * [Golang bindings for the Telegram Bot API](https://github.com/go-telegram-bot-api/telegram-bot-api)\n  * [shell2http - shell commands as http-server](https://github.com/msoap/shell2http)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsoap%2Fshell2telegram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsoap%2Fshell2telegram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsoap%2Fshell2telegram/lists"}