Looking for a chat system (here's one!)
Robec Horsham PM
eli at robechq.UUCP
Tue Jul 18 22:42:14 AEST 1989
In article <144100005 at cdp> mgraham at cdp.UUCP writes:
>
>I am looking for a chat system to run under Xenix 2.2.3.
>
Please, no flames on the long posting. As you can see,
I copied this out of UNIX WORLD, a fine magazine for
UNIX people. I thought that I'd save you some typing.
(I hope that I typed it in correctly :-)
Eli Levine @Robec Distributors
:
# @(#) chat Converse with one or more users
# Author: Burton A. Hipp
# from UNIX WORLD, Wizard's Grabbag, Jan 89
#
trap '$Auto && Auto=false && > $MyQ; continue' 2 3
umask 000; Auto=false; Prompt="$LOGNAME ->"
#
Help='Chat Commands are:
~! - shell out to system
~h - help, show this screen
~c - clear screen
~s - status, display users in this group
~l - list all groups and users
~u - users on this system
~a - auto mode, dump your message queue continuously
~q - quit chat
~d - display date and time
~t - tail the logfile, show previous conversation
~b - buffer your input and send all at once
~p - modify your prompt
~i user - invite a user into your group
~j group - join a different group
~w user text - whisper to someone'
Usage='Usage: chat person [tty]'
InvUsage='Usage: ~i person [tty]'
InvMsg="To chat with $LOGNAME use \"chat $LOGNAME\"."
WhisUsage='Usage: ~w person text'
ReturnMsg='Type "exit" to return to chat.'
AutoMsg='AUTO MODE is ON. INTR key to end.'
NoPers='No such person. Use ~s to display users (status).'
NoGrp='No such group. Use ~l to list groups and users.'
MesgNo='This person has their mesg set to n, cannot invite.'
Speak='for Q in /tmp/*$Gid.q
do
[ $Q = $MyQ ] && continue
echo "$Words" >> $Q
done'
#
if [ $# -eq 0 ]; then
cat -s /tmp/Group*[!q] && echo
echo $Usage; exit
fi
#
Who=`who | grep "^$1 *$2"`
case "$Who" in
$1*$1*)echo "Too many $1's on.\n$Usage"; exit 2;;
'') echo "$1 is not logged on."; exit 2;;
esac
#
Gid=`grep -l "$Who" /tmp/Group*[!q] 2>/dev/null | tr -cd '[0-9]'`
if [ -z "$Gid" ]; then
set - $Who
( echo $InvMsg > /dev/$2 ) 2> /dev/null
[ $? -ne 0 ] && echo $MesgNo && exit
echo "\nGROUP $$\n-------------" > /tmp/Group${Gid:=$$}
fi
#
MyQ=/tmp/$LOGNAME$Gid.q
GroupQ=/tmp/Group$Gid.q
GroupData=/tmp/Group$Gid
#
who am i >> $GroupData
touch $MyQ $GroupQ
#
Words="[$LOGNAME enter]"
eval "$Speak"
#
while :
do
echo "$Prompt \c"
read Words
set - $Words
case "$Words" in
"") [ -s $MyQ ] && cat $MyQ && > $MyQ;;
~!) echo $ReturnMsg; PS1='Chat$ ' ${SHELL:=/bin/sh};;
~!!) set - $Last; IFS=~! sh -c "$*";;
~!*) Last=$*; IFS=~! sh -c "$*";;
~s*) cat $GroupData;;
~l*) cat /tmp/Group*[!q];;
~d*) date;;
~t*) tail $2 $GroupQ;;
~p*) shift; Prompt=${*:-"$Prompt"};;
~q*) break;;
~u*) who;;
~c*) tput clear;;
~a*) Auto=true; echo $AutoMsg; tail +0f $MyQ;;
~h*|\?) echo "$Help";;
~e*) tail /tmp/Group$2.q 2>/dev/null || echo $NoGrp;;
~w*) [ -z "$2" ] && echo $WhisUsage && continue
[ ! -f /tmp/"$2$Gid.q" ] && echo $NoPers && continue
To=$2; shift 2
echo "$LOGNAME whispered: $*" >> /tmp/$To$Gid.q;;
~b*) Words="$LOGNAME: "
while read BuffInput; do
Words="${Words}${BuffInput}\n"
done
eval "$Speak";;
~i*) [ $# -eq 1 ] && echo $InvUsage && continue
Name_tty=`who | grep "^$2 *$3"`
case "$Name_tty" in
$2*$2*) echo "Too many $2's on.\n$InvUsage"
continue;;
'') echo "$2 is not logged on."; continue;;
esac
set - $Name_tty
( echo $InvMsg > /dev/$2 ) 2> /dev/null
[ $? -ne 0 ] && echo $MesgNo;;
~j*) [ $# -eq 1 ] && echo Usage: ~j group && continue
[ ! -f /tmp/Group$2 ] && echo $NoGrp && continue
echo "Switching to group $2..."
Switch="exec $0 `tail -l /tmp/Group$2`"
break;;
~*) echo Unknown command.;;
*) Words="$LOGNAME: $Words"; eval "$Speak";;
esac
done
#
grep -v "`who am i`" $GroupData > /tmp/chat$$
mv /tmp/chat$$ $GroupData
if [ `wc -l < $GroupData` -eq 3 ]; then
rm $GroupData $GroupQ > /dev/null 2>&1
else
Words="[$LOGNAME exited]"
eval "$Speak"
fi
rm $MyQ > /dev/null 2>&1
$Switch
----------------------------
That's all folks
--
*********************************************
Eli Levine @Robec Distributors
(215) 675-9500
*********************************************
More information about the Comp.unix.xenix
mailing list