1
0
mirror of https://github.com/danog/id3bot.git synced 2024-11-30 04:19:02 +01:00

Fixed other bugs

This commit is contained in:
Daniil Gentili 2016-01-25 13:37:05 +01:00
parent 931cf51a7c
commit 6e3e156f42

View File

@ -142,25 +142,22 @@ forward() {
res=$(curl -s "$FORWARD_URL" -F "chat_id=$1" -F "from_chat_id=$2" -F "message_id=$3") res=$(curl -s "$FORWARD_URL" -F "chat_id=$1" -F "from_chat_id=$2" -F "message_id=$3")
} }
startproc() { startproc() {
mkdir -p "$copname" rm -r $copname
mkfifo $copname/out mkfifo $copname
tmux kill-session -t $copname tmux kill-session -t $copname
tmux new-session -d -s $copname "./question &>$copname/out" tmux new-session -d -s $copname "./question &>$copname"
local pid=$(ps aux | sed '/tmux/!d;/'$copname'/!d;/sed/d;s/'$USER'\s*//g;s/\s.*//g') while tmux ls | grep -q $copname;do
echo $pid>$copname/pid
while ps aux | grep -v grep | grep -q $pid;do
read -t 10 line read -t 10 line
[ "$line" != "" ] && send_message "${USER[ID]}" "$line" [ "$line" != "" ] && send_message "${USER[ID]}" "$line"
line= line=
done <$copname/out done <$copname
rm -r $copname
} }
inproc() { inproc() {
tmux send-keys -t $copname "$MESSAGE ${URLS[*]} tmux send-keys -t $copname "$MESSAGE ${URLS[*]}
" "
ps aux | grep -v grep | grep -q "$copid" || { rm -r $copname; };
} }
process_client() { process_client() {
@ -198,16 +195,14 @@ process_client() {
# Tmux # Tmux
copname="CO${USER[ID]}" copname="CO${USER[ID]}"
copidname="$copname/pid"
copid="$(cat $copidname 2>/dev/null)"
if [ "$copid" = "" ]; then if ! tmux ls | grep -q $copname; then
[ ! -z "${URLS[*]}" ] && { [ ! -z ${URLS[*]} ] && {
curl -s ${URLS[*]} -o $NAME curl -s ${URLS[*]} -o $NAME
send_file "${USER[ID]}" "$NAME" "$CAPTION" send_file "${USER[ID]}" "$NAME" "$CAPTION"
rm "$NAME" rm "$NAME"
} }
[ ! -z "${LOCATION[*]}" ] && send_location "${USER[ID]}" "${LOCATION[LATITUDE]}" "${LOCATION[LONGITUDE]}" [ ! -z ${LOCATION[*]} ] && send_location "${USER[ID]}" "${LOCATION[LATITUDE]}" "${LOCATION[LONGITUDE]}"
case $MESSAGE in case $MESSAGE in
'/question') '/question')
startproc& startproc&