some typo, specify exit codes

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2019-04-01 12:52:25 +02:00
parent 92e9e9c3f5
commit 352c64fc32
4 changed files with 23 additions and 13 deletions

View File

@ -213,7 +213,7 @@ Allowed values: typing for text messages, upload_photo for photos, record_video
send_action "${CHAT[ID]}" "action" send_action "${CHAT[ID]}" "action"
``` ```
#### Interactice Chats #### Interactive Chats
To create interactive chats, write (or edit the question script) a normal bash (or C or python) script, chmod +x it and then change the argument of the startproc function to match the command you usually use to start the script. To create interactive chats, write (or edit the question script) a normal bash (or C or python) script, chmod +x it and then change the argument of the startproc function to match the command you usually use to start the script.
The text that the script will output will be sent in real time to the user, and all user input will be sent to the script (as long as it's running or until the user kills it with /cancel). The text that the script will output will be sent in real time to the user, and all user input will be sent to the script (as long as it's running or until the user kills it with /cancel).
To open up a keyboard in an interactive script, print out the keyboard layout in the following way: To open up a keyboard in an interactive script, print out the keyboard layout in the following way:
@ -418,7 +418,7 @@ To use bashbot as a system servive include a working ```bashbot.rc``` in your in
An example crontab is provided in ```bashbot.cron```. An example crontab is provided in ```bashbot.cron```.
- If you are running bashbot with your user-ID, copy the examples lines to your crontab and remove username ```nobody```. - If you are running bashbot with your user-ID, copy the examples lines to your crontab and remove username ```nobody```.
- if you run bashbot as an other user or a system service edit ```bashbot.cron``` to fit your needs and replace username````nobody``` with the username you want to run bashbot. copy the modified file to ```/etc/cron.d/bashbot``` - if you run bashbot as an other user or a system service edit ```bashbot.cron``` to fit your needs and replace username```nobody``` with the username you want to run bashbot. copy the modified file to ```/etc/cron.d/bashbot```
## Security Considerations ## Security Considerations
@ -439,10 +439,10 @@ Everyone who can read your Bot files can extract your Bots data. Especially your
Runing ```./bashbot init``` sets the Bot permissions to reasonable default values as a starting point. Runing ```./bashbot init``` sets the Bot permissions to reasonable default values as a starting point.
### Is this Bot insecure? ### Is this Bot insecure?
No - its not more or less insecure as any other Bot written in any other language. But you should know about the implications ... No - its not less (in)secure as any other Bot written in any other language. But you should know about the implications ...
## That's it! ## That's it!
If you feel that there's something missing or if you found a bug, feel free to submit a pull request! If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
#### $$VERSION$$ v0.5-rc-3-gf67503c #### $$VERSION$$ v0.5-rc-4-g92e9e9c

View File

@ -7,7 +7,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.5-rc-3-gf67503c #### $$VERSION$$ v0.5-rc-4-g92e9e9c
SHELL=/bin/sh SHELL=/bin/sh

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# description: Start or stop telegram-bash-bot # description: Start or stop telegram-bash-bot
# #
#### $$VERSION$$ v0.5-rc-3-gf67503c #### $$VERSION$$ v0.5-rc-4-g92e9e9c
# #
### BEGIN INIT INFO ### BEGIN INIT INFO
# Provides: bashbot # Provides: bashbot
@ -13,7 +13,7 @@
### END INIT INFO ### END INIT INFO
runas="root" # not recommended! runas="root" # not recommended!
runcmd="echo" # not actived until you edit lines below runcmd="echo Dry run:" # not actived until you edit lines below
# uncomment the next line to run as other user, e.g. www # uncomment the next line to run as other user, e.g. www
# runas="nobody" # runas="nobody"

View File

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
# bashbot, the Telegram bot written in bash. # bashbot, the Telegram bot written in bash.
# Written by Drew (@topkecleon) and Daniil Gentili (@danogentili). # Written by Drew (@topkecleon) and Daniil Gentili (@danogentili), KayM (@gnadelwartz).
# Also contributed: JuanPotato, BigNerd95, TiagoDanin, iicc1, Gnadelwartz. # Also contributed: JuanPotato, BigNerd95, TiagoDanin, iicc1.
# https://github.com/topkecleon/telegram-bot-bash # https://github.com/topkecleon/telegram-bot-bash
# Depends on JSON.sh (http://github.com/dominictarr/JSON.sh) (MIT/Apache), # Depends on JSON.sh (http://github.com/dominictarr/JSON.sh) (MIT/Apache),
@ -10,7 +10,14 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.5-rc-3-gf67503c #### $$VERSION$$ v0.5-rc-4-g92e9e9c
#
# Exit Codes:
# - 0 sucess (hopefully)
# - 1 can't change to bashbot dir
# - 2 can't write to tmp and / or count
# - 3 user not found
# - 4 unkown command
# are we runnig in a terminal? # are we runnig in a terminal?
if [ -t 1 ] && [ "$TERM" != "" ]; then if [ -t 1 ] && [ "$TERM" != "" ]; then
@ -56,7 +63,7 @@ elif [ ! -w "$TMPDIR" ]; then
$CLEAR $CLEAR
echo -e "${RED}ERROR: Can't write to $TMPDIR!.${NC}" echo -e "${RED}ERROR: Can't write to $TMPDIR!.${NC}"
ls -ld "$TMPDIR" ls -ld "$TMPDIR"
exit 1 exit 2
fi fi
COUNT="./count" COUNT="./count"
@ -66,7 +73,7 @@ elif [ ! -w "$COUNT" ]; then
$CLEAR $CLEAR
echo -e "${RED}ERROR: Can't write to $COUNT!.${NC}" echo -e "${RED}ERROR: Can't write to $COUNT!.${NC}"
ls -l "$COUNT" ls -l "$COUNT"
exit 1 exit 2
fi fi
@ -551,7 +558,7 @@ case "$1" in
[ "$TOUSER" = "" ] && TOUSER="$MYUSER" [ "$TOUSER" = "" ] && TOUSER="$MYUSER"
if ! compgen -u "$TOUSER" 2>&1 >/dev/null; then if ! compgen -u "$TOUSER" 2>&1 >/dev/null; then
echo -e "${RED}User \"$TOUSER\" not found!${NC}" echo -e "${RED}User \"$TOUSER\" not found!${NC}"
exit 2 exit 3
else else
echo "Adjusting user in bashbot.rc ..." echo "Adjusting user in bashbot.rc ..."
sed -i '/^[# ]*runas=/ s/runas=.*$/runas="'$TOUSER'"/' bashbot.rc sed -i '/^[# ]*runas=/ s/runas=.*$/runas="'$TOUSER'"/' bashbot.rc
@ -611,16 +618,19 @@ case "$1" in
"help") "help")
$CLEAR $CLEAR
less "README.md" less "README.md"
exit
;; ;;
"attach") "attach")
tmux attach -t "$ME" tmux attach -t "$ME"
;; ;;
"source") "source")
echo "OK" echo "OK"
exit
;; ;;
*) *)
echo -e "${RED}BAD REQUEST${NC}" echo -e "${RED}BAD REQUEST${NC}"
echo -e "${RED}Available arguments: outproc, count, broadcast, start, suspendback, resumeback, kill, killback, help, attach${NC}" echo -e "${RED}Available arguments: outproc, count, broadcast, start, suspendback, resumeback, kill, killback, help, attach${NC}"
exit 4
;; ;;
esac esac