All Projects → msoap → shell2telegram

msoap / shell2telegram

Licence: MIT license
Telegram bot constructor from command-line

Programming Languages

go
31211 projects - #10 most used programming language
Roff
2310 projects
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to shell2telegram

SophiaBot
Hi There ✋ I'M Sophia 3.0 ❤️ NEW VERSION OF SOPHIA.. Source Code of @SophiaSLBot.
Stars: ✭ 44 (-62.39%)
Mutual labels:  telegram-bots
TelegramScraper
Using this tool you can easily add so many members from any group to your group. Less than 2 minutes. Super easy. Time saver. But this tool is only for educational purpose. You could be banned from Telegram. So be careful. Recommanded to use this tool only on Termux.
Stars: ✭ 234 (+100%)
Mutual labels:  telegram-bots
botter
🤖 Build Amazing Telegram Bots with PHP
Stars: ✭ 24 (-79.49%)
Mutual labels:  telegram-bots
github client
Open source bot telegram menggunakan bahasa code dart
Stars: ✭ 24 (-79.49%)
Mutual labels:  telegram-bots
joinhider bot
Telegram bot to delete user joined messages
Stars: ✭ 20 (-82.91%)
Mutual labels:  telegram-bots
nosticker bot
Bot that fights telegram stickers
Stars: ✭ 18 (-84.62%)
Mutual labels:  telegram-bots
telresender
A Telegram bot, which resend your message to another account
Stars: ✭ 22 (-81.2%)
Mutual labels:  telegram-bots
FreeSteamGames-TelegramBot
A Telegram Bot that sends you a message when a game on steam is free
Stars: ✭ 35 (-70.09%)
Mutual labels:  telegram-bots
TelegramBotsList
A list of all Telegram bots source hosted on github.
Stars: ✭ 277 (+136.75%)
Mutual labels:  telegram-bots
Triton
GitHub notifications tracker for Telegram. Pushes GitHub notifications to Telegram.
Stars: ✭ 12 (-89.74%)
Mutual labels:  telegram-bots
tdlight-java
Complete Bot and Userbot Telegram library based on TDLib
Stars: ✭ 128 (+9.4%)
Mutual labels:  telegram-bots
RPi-TELEBOT
Python based Telegram bot to monitor and control the raspberry pi
Stars: ✭ 19 (-83.76%)
Mutual labels:  telegram-bots
Telegram-mailer
Web-application for sending messages to list of users. Use several accounts to avoid ban.
Stars: ✭ 28 (-76.07%)
Mutual labels:  telegram-bots
telegram-bot-sdk
🤖 Telegram Bot API PHP SDK. Create Telegram Bots with PHP Easily! [WIP - DO NOT USE IN PRODUCTION YET]
Stars: ✭ 64 (-45.3%)
Mutual labels:  telegram-bots
tdlight-telegram-bot-api
The TDLight Telegram Bot API is an actively enhanced fork of the original Bot API, featuring experimental user support, proxies, unlimited files size, and more.
Stars: ✭ 71 (-39.32%)
Mutual labels:  telegram-bots
Nutgram
The Telegram bot framework that doesn't drive you nuts.
Stars: ✭ 206 (+76.07%)
Mutual labels:  telegram-bots
shop-telegram-bot
Java shop chatbot for Telegram
Stars: ✭ 71 (-39.32%)
Mutual labels:  telegram-bots
telegram
📚 Golang bindings for Telegram API
Stars: ✭ 15 (-87.18%)
Mutual labels:  telegram-bots
grouphelperbot
A Telegram Bot made to help group admins, with Italian/English support.
Stars: ✭ 26 (-77.78%)
Mutual labels:  telegram-bots
Sophie
New repo - https://gitlab.com/SophieBot/sophie
Stars: ✭ 28 (-76.07%)
Mutual labels:  telegram-bots

shell2telegram

Go build status Coverage Status Docker Pulls Homebrew formula exists Report Card

Create Telegram bot from command-line

Install

MacOS:

brew tap msoap/tools
brew install shell2telegram
# update:
brew upgrade shell2telegram

Or download binaries from: releases (OS X/Linux/Windows/RaspberryPi)

Or build from source:

# set $GOPATH if needed
go install github.com/msoap/shell2telegram@latest
ln -s $GOPATH/bin/shell2telegram ~/bin/shell2telegram # or add $GOPATH/bin to $PATH

Or build image and run with Docker. Example of test-bot.Dockerfile for bot who say current date:

FROM msoap/shell2telegram
# may be install some alpine packages:
# RUN apk add --no-cache ...
ENV TB_TOKEN=*******
CMD ["/date", "date"]

And build and run:

docker build -f test-bot.Dockerfile -t test-bot .
docker run --rm test-bot
# or run with set token from command line
docker run -e TB_TOKEN=******* --rm test-bot

Using snap (Ubuntu or any Linux distribution with snap):

# install stable version:
sudo snap install shell2telegram

# install the latest version:
sudo snap install --edge shell2telegram

# update
sudo snap refresh shell2telegram

Notice: the snap-package has its own sandbox with the /bin, /usr/bin directories which are not equal to system-wide PATH directories.

Usage

Get token from BotFather bot, and set TB_TOKEN var in shell

export TB_TOKEN=*******
shell2telegram [options] /chat_command 'shell command' /chat_command2 'shell command2'
options:
    -allow-users=<NAMES> : telegram users who are allowed to chat with the bot ("user1,user2")
    -root-users=<NAMES>  : telegram users, who confirms new users in their private chat ("user1,user2")
    -allow-all           : allow all users (DANGEROUS!)
    -add-exit            : adding "/shell2telegram exit" command for terminate bot (for roots only)
    -log-commands        : logging all commands
    -tb-token=<TOKEN>    : setting bot token (or set TB_TOKEN variable)
    -timeout=N           : setting timeout for bot (default 60 sec)
    -description=<TITLE> : setting description of bot
    -bind-addr=<ADDRESS> : address to listen incoming webhook requests
    -webhook=<URL>       : url for registering a webhook
    -persistent-users    : load/save users from file (default ~/.config/shell2telegram.json)
    -users-db=<FILENAME> : file for store users
    -cache=N             : caching command out for N seconds
    -one-thread          : run each shell command in one thread
    -public              : bot is public (don't add /auth* commands)
    -sh-timeout=N        : set timeout for execute shell command (in seconds)
    -shell="shell"       : shell for execute command, "" - without shell (default "sh")
    -version
    -help

If not define -allow-users/-root-users options - authorize users via secret code from console or via chat with exists root users.

All text after /chat_command will be sent to STDIN of shell command.

Special chat commands

for private chats only:

  • /:plain_text - get user message without any /command.

TODO:

  • /:image - for get image from user. Example: /:image 'cat > file.jpg; echo ok'
  • /:file - for get file from user
  • /:location - for get geo-location from user

Possible long-running shell processes (for example alarm/timer bot).

Autodetect images (png/jpg/gif/bmp) out from shell command, for example: /get_image 'cat file.png'

Setting environment variables for shell commands:

  • S2T_LOGIN - telegram @login (may be empty)
  • S2T_USERID - telegram user ID
  • S2T_USERNAME - telegram user name
  • S2T_CHATID - chat ID

Modificators for bot commands

  • :desc - setting the description of command, /cmd:desc="Command name" 'shell cmd'
  • :vars - to create environment variables instead of text output to STDIN, /cmd:vars=VAR1,VAR2 'echo $VAR1 / $VAR2'
  • :md - to send message as markdown text, /cmd:md 'echo "*bold* and _italic_"'

TODO:

  • /cmd:cron=3600 — periodic exec command, /cmd:on args - on, /cmd:off - off

Predefined bot commands

  • /help - list available commands
  • /auth - begin authorize new user
  • /auth <CODE> - authorize with code from console or from exists root user
  • /authroot - same for new root user
  • /authroot <CODE> - same for new root user

for root users only:

  • /shell2telegram stat - show users statistics
  • /shell2telegram search <query> - search users by name/id
  • /shell2telegram ban <user_id|@username> - ban user
  • /shell2telegram exit - terminate bot (for run with -add-exit)
  • /shell2telegram desc <description> - set bot description
  • /shell2telegram rm </command> - delete command
  • /shell2telegram broadcast_to_root <message> - send message to all root users in private chat
  • /shell2telegram message_to_user <user_id|@username> <message> - send message to user in private chat
  • /shell2telegram version - show version

Examples

# system information
shell2telegram /top:desc="System information" 'top -l 1 | head -10' /date 'date' /ps 'ps aux -m | head -20'

# sort any input
shell2telegram /:plain_text sort

# alarm bot:
# /alarm time_in_seconds message
shell2telegram /alarm:vars=SLEEP,MSG 'sleep $SLEEP; echo Hello $S2T_USERNAME; echo Alarm: $MSG'

# sound volume control via telegram (Mac OS)
shell2telegram /get  'osascript -e "output volume of (get volume settings)"' \
               /up   'osascript -e "set volume output volume (($(osascript -e "output volume of (get volume settings)")+10))"' \
               /down 'osascript -e "set volume output volume (($(osascript -e "output volume of (get volume settings)")-10))"'

# using with webhook instead of poll
shell2telegram -bind-addr=0.0.0.0:8080 -webhook=https://bot.example.com/path/to/bot \
               /date /date

# command with Markdown formating, calendar in monospace font
shell2telegram /cal:md 'echo "\`\`\`$(ncal)\`\`\`"'

Links

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].