Skip to content

Instantly share code, notes, and snippets.

@i-sync
Created August 10, 2017 04:30
Show Gist options
  • Save i-sync/29c8315d8704b7d5e87d3314bd3eba7b to your computer and use it in GitHub Desktop.
Save i-sync/29c8315d8704b7d5e87d3314bd3eba7b to your computer and use it in GitHub Desktop.
play telegram bot voice
#!/bin/bash
#this file is check "voice.sh" script whether is running
#if "voice.sh" script is running , nothing to do
#else run "voice.sh" script
result=`ps aux | grep -i "voice.sh" | grep -v "grep" | wc -l`
echo $result
if [ $result -ge 1 ]
then
echo "voice.sh is running..."
#/bin/bash /home/pi/sh/voice.sh
else
echo "voice.sh is not running..."
echo "start voice.sh script..."
#check mpc is playing , pause
playing=`mpc | grep playing | wc -l`
if [ $playing -ge 1 ]
then
mpc pause
fi
#run voice.sh
/bin/bash /home/pi/sh/voice.sh
#check mpc is pause, resume
paused=`mpc | grep paused | wc -l`
if [ $paused -ge 1 ]
then
mpc play
fi
fi
#!/bin/bash
#this file is really play script
#check telegram bot voice path
path=~/tmp/*
#voice backup folder
backup=~/tmp/backup
#use mplayer play telegram bot voice
player=/usr/bin/mplayer
#reminder voice
reminder=~/tmp/remind/reminder.mp3
#if first voice, play reminder voice
flag=true
for file in $path
do
#check $file whether is file
if [ -f $file ];then
#echo $file
if [ "$flag" ] ; then
$player $reminder
flag=false
fi
$player $file
$player $file
mv $file $backup
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment