mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-12-29 13:12:36 +00:00
Merge pull request #61 from gnadelwartz/master
fix restart in rc file, add init command to setup bashbot environment
This commit is contained in:
commit
492de26344
17
README.md
17
README.md
@ -4,6 +4,11 @@ A Telegram bot written in bash.
|
||||
Depends on [tmux](http://github.com/tmux/tmux).
|
||||
Uses [JSON.sh](http://github.com/dominictarr/JSON.sh).
|
||||
|
||||
Written by Drew (@topkecleon) and Daniil Gentili (@danogentili).
|
||||
Also contributed: JuanPotato, BigNerd95, TiagoDanin, iicc1, Kay M (@gnadelwartz).
|
||||
|
||||
[Download from github](https://github.com/topkecleon/telegram-bot-bash)
|
||||
|
||||
Released to the public domain wherever applicable.
|
||||
Elsewhere, consider it released under the [WTFPLv2](http://www.wtfpl.net/txt/copying/).
|
||||
|
||||
@ -69,13 +74,19 @@ group. This step is up to you actually.
|
||||
13. @botfather replies with `Success! The new status is: DISABLED. /help`
|
||||
|
||||
### Install bashbot
|
||||
Clone the repository:
|
||||
1. Go to the directory you want to install bashbot, e.g.
|
||||
|
||||
- your $HOME directory (install and run with your user-ID)
|
||||
- /usr/local if you want to run as service
|
||||
|
||||
2. Clone the repository:
|
||||
```
|
||||
git clone --recursive https://github.com/topkecleon/telegram-bot-bash
|
||||
```
|
||||
3. Change to directory ```telegram-bot.bash``` and run ```./bashbot.sh init``` and follow the instructions.
|
||||
|
||||
Create a file called token and paste the token in there.
|
||||
Then start editing the commands.
|
||||
|
||||
Then start editing the commands.sh.
|
||||
|
||||
### Receive data
|
||||
You can read incoming data using the following variables:
|
||||
|
13
bashbot.rc
13
bashbot.rc
@ -11,7 +11,7 @@
|
||||
### END INIT INFO
|
||||
|
||||
runas="root" # not recommended!
|
||||
runcmd="echo" # not activated until you edit lines below
|
||||
runcmd="echo" # not actived until you edit lines below
|
||||
|
||||
# uncomment the next line to run as other user, e.g. www
|
||||
# runas="www"
|
||||
@ -20,10 +20,10 @@ runcmd="echo" # not activated until you edit lines below
|
||||
# runcmd="su $runas -s /bin/bash -c " # runasuser with su
|
||||
# runcmd="runuser $runas -s /bin/bash -c " # runasuser with runuser
|
||||
|
||||
# uncomment and adjust the the values of the following lines
|
||||
# start="/usr/local/telegram-bot-bash/bashbot.sh"
|
||||
# lockfile=/usr/local/telegram-bot-bash/lockfile
|
||||
# name='new-session' # telegram name of your bot
|
||||
# adjust the the values of the following lines
|
||||
start="/usr/local/telegram-bot-bash/bashbot.sh"
|
||||
lockfile=/usr/local/telegram-bot-bash/lockfile
|
||||
name='new-session' # telegram name of your bot
|
||||
|
||||
|
||||
case "$1" in
|
||||
@ -52,11 +52,12 @@ case "$1" in
|
||||
fi
|
||||
;;
|
||||
'restart'|'reload')
|
||||
$stop ; $start
|
||||
$0 stop; $0 start
|
||||
RETVAL=$?
|
||||
;;
|
||||
'suspendback'|'resumeback'|'killback')
|
||||
$runcmd "$start $1"
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 { start | stop | restart | reload | suspendback | resumeback | killback }"
|
||||
|
20
bashbot.sh
20
bashbot.sh
@ -525,6 +525,26 @@ case "$1" in
|
||||
echo "Tmux session name $ME" || echo -e '\e[0;31mAn error occurred while starting the bot. \e[0m'
|
||||
send_markdown_message "${CHAT[ID]}" "*Bot started*"
|
||||
;;
|
||||
"init") # adjust users and permissions
|
||||
MYUSER="$USER"
|
||||
[[ $(id -u) -eq 0 ]] && MYUSER="www"
|
||||
echo -n "Enter User to run basbot [$MYUSER]: "
|
||||
read TOUSER
|
||||
[ "$TOUSER" = "" ] && TOUSER="$MYUSER"
|
||||
if ! compgen -u "$TOUSER" 2>&1 >/dev/null; then
|
||||
echo -e "\e[0;31mUser \"$TOUSER\" not found!\e[0m"
|
||||
exit 2
|
||||
else
|
||||
echo "Adjusting Owner and Permissions ..."
|
||||
chown -R "$TOUSER" . *
|
||||
chmod 711 .
|
||||
chmod -R a-w *
|
||||
chmod u+w "$COUNT" "$TMPDIR" *.log
|
||||
chmod o-r,o-w "$COUNT" "$TMPDIR" token
|
||||
ls -la
|
||||
exit
|
||||
fi
|
||||
;;
|
||||
"background" | "resumeback")
|
||||
clear
|
||||
echo -e '\e[0;32mRestart background processes ...\e[0m'
|
||||
|
Loading…
Reference in New Issue
Block a user