From 495c23def4e696f7ecd6da91bed69c9fb45a7458 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 15 Apr 2016 19:25:43 +0200 Subject: [PATCH] Fixed bug when script prints content right before exiting --- bashbot.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index 9c43212..8f96806 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -148,16 +148,16 @@ forward() { } startproc() { - rm -r $copname + (rm -r $copname + tmux kill-session -t $copname)2>/dev/null + mkfifo $copname - tmux kill-session -t $copname - TMUX= tmux new-session -d -s $copname "./question &>$copname" - while tmux ls | grep -q $copname;do + TMUX= tmux new-session -d -s $copname "./question &>$copname; sleep 10; rm -r $copname" + while [ -p "$copname" ];do read -t 10 line [ "$line" != "" ] && send_message "${USER[ID]}" "$line" line= done <$copname - rm -r $copname } inproc() { @@ -225,7 +225,7 @@ Available commands: /info: Get shorter info message about this bot. /question: Start interactive chat. /cancel: Cancel any currently running interactive chats. -Written by @topkecleon, Juan Potato (@awkward_potato), Lorenzo Santina (BigNerd95) and Daniil Gentili (danog) +Written by @topkecleon, Juan Potato (@awkward_potato), Lorenzo Santina (BigNerd95) and Daniil Gentili (@danogentili) Contribute to the project: https://github.com/topkecleon/telegram-bot-bash " ;;