fix silly carage returns and chat works

This commit is contained in:
vulpine 2020-07-31 01:22:14 +00:00
parent a03a9fcf26
commit 47f3aefb6b
2 changed files with 35 additions and 2 deletions

View File

@ -1,3 +1,36 @@
#!/bin/sh
#!/bin/bash
echo 'press some ranodm keys and enter or something to type stuff'
echo "currently open rooms: "`ls data/chat`
echo 'JOIN'
read CHATROOM
echo 'NICK'
read NICK
mkdir -p data/chat
touch "data/chat/$CHATROOM"
touch data/nicks
if grep -Fxq "$NICK" data/nicks
then
echo 'that nick is taken :('
exit
else
echo "$NICK" >> data/nicks
fi
LNSRED=0
while [ 1 ]; do
tail -n "+$LNSRED" "data/chat/$CHATROOM"
LNSRED=$(wc -l "data/chat/$CHATROOM" | awk 'END {print $1+1}')
TEXT=''
read -t 1 -d '' KPR
if [ "$KPR" != "" ];then
echo 'input text'
read TEXT
fi
[ "$TEXT" = "" ] || echo `date -Iseconds`" <$NICK> $TEXT" >> "data/chat/$CHATROOM"
done

View File

@ -9,6 +9,6 @@ PORT=7777
socat tcp-l:$PORT,reuseaddr,fork system:'tr -d "\r" | ./bbsui.sh'
socat tcp-l:$PORT,reuseaddr,fork,crnl system:'./bbsui.sh'