#!/bin/bash
CONTACT_UIN=$1
EVENT_NETWORK=$2
declare -i TIMEOFFSET=300 #play the alternate sound if the last message is not older than 300 seconds

cd /tmp
declare -i PREVTIMEux=`date +%s`-$TIMEOFFSET
PREVTIME=`/usr/bin/perl -e 'print scalar localtime shift' $PREVTIMEux`
/usr/bin/touch -d "$PREVTIME" cicq_REF
/usr/bin/find . -maxdepth 1 -newer cicq_REF | /bin/grep "cicq_${EVENT_NETWORK}_${CONTACT_UIN}"
if [ $? -eq 0 ] ; then
	/usr/bin/esdplay /work/icqsounds/receive.wav &
else
	/usr/bin/esdplay /work/icqsounds/Message.wav &
fi

/usr/bin/touch "/tmp/cicq_${EVENT_NETWORK}_${CONTACT_UIN}"
