diff --git a/README.md b/README.md index acadd7e..5c0ec6c 100644 --- a/README.md +++ b/README.md @@ -157,8 +157,8 @@ echo "Text that will appear in chat? mykeyboardstartshere \"Yep, sure\" \"No, hi ``` -Once you're done editing start the bot with ```tmux new-session -d -s bashbot "./bashbot.sh"```. -To stop the bot run ```tmux kill-session -t bashbot```. +Once you're done editing start the bot with ```./bashbot.sh start```. +To stop the bot run ```./bashbot.sh kill```. If some thing doesn't work as it should, debug with ```bash -x bashbot.sh```. To use the functions provided in this script in other scripts source bashbot.sh: ```source bashbot.sh source``` diff --git a/bashbot.sh b/bashbot.sh index 60bfb14..89b2c51 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -13,6 +13,7 @@ # If you're in Europe, and public domain does not exist, then haha. TOKEN='tokenhere' +TOKEN='197476763:AAGj-kg10J97h7t57DawEJYs_ljxKFuKaJ0' URL='https://api.telegram.org/bot'$TOKEN # Set INLINE to 1 in order to receive inline queries. @@ -367,7 +368,7 @@ Contribute to the project: https://github.com/topkecleon/telegram-bot-bash } # source the script with source as param to use functions in other scripts -while [ "$1" == "" ]; do { +while [ "$1" == "startbot" ]; do { res=$(curl -s $UPD_URL$OFFSET | ./JSON.sh -s) @@ -400,5 +401,15 @@ case "$1" in shift for f in $(cat count);do send_message ${f//COUNT} "$*"; $sleep;done ;; - + "start") + tmux kill-session -t $ME&>/dev/null + tmux new-session -d -s $ME "bash $SCRIPT startbot" && echo "Bot started successfully. Tmux session name is $ME" || echo "An error occurred while starting the bot." + ;; + "kill") + tmux kill-session -t $ME &>/dev/null + echo "Bot was killed successfully. " + ;; + "help") + cat README.md + ;; esac