From 6ad35f34d7ca525506963d004b091e4c662be685 Mon Sep 17 00:00:00 2001 From: Ignacio Iglesias Date: Sat, 26 Mar 2016 23:31:47 +0100 Subject: [PATCH] Updated nested tmux and fixed username in chats With the: ''TMUX= tmux new-session -d -s ....'' addition, now interactive chats work when you are running the bot inside a tmux session. Before, USER[USERNAME] was not getting the username of the user in groups, now it is solved. --- bashbot.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index ff20a79..9c43212 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -151,7 +151,7 @@ startproc() { rm -r $copname mkfifo $copname tmux kill-session -t $copname - tmux new-session -d -s $copname "./question &>$copname" + TMUX= tmux new-session -d -s $copname "./question &>$copname" while tmux ls | grep -q $copname;do read -t 10 line [ "$line" != "" ] && send_message "${USER[ID]}" "$line" @@ -169,7 +169,7 @@ process_client() { # User USER[FIRST_NAME]=$(echo "$res" | egrep '\["result",0,"message","chat","first_name"\]' | cut -f 2 | cut -d '"' -f 2) USER[LAST_NAME]=$(echo "$res" | egrep '\["result",0,"message","chat","last_name"\]' | cut -f 2 | cut -d '"' -f 2) - USER[USERNAME]=$(echo "$res" | egrep '\["result",0,"message","chat","username"\]' | cut -f 2 | cut -d '"' -f 2) + USER[USERNAME]=$(echo "$res" | sed 's/^.*\(username.*\)/\1/g' | cut -d '"' -f3) # Audio URLS[AUDIO]=$(get_file $(echo "$res" | egrep '\["result",0,"message","audio","file_id"\]' | cut -f 2 | cut -d '"' -f 2))