-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtelnet_client.sh
More file actions
49 lines (43 loc) · 1.01 KB
/
Copy pathtelnet_client.sh
File metadata and controls
49 lines (43 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
menu()
{
printf "\033[2J"
echo "+--------------------------+"
echo "| Awkventure telnet server |"
echo "+--------------------------+"
echo ""
echo " P)lay as guest"
echo " E)xit"
echo ""
read -n 1 command
if echo $command | grep -Eq '^[Pp|Play|play]'; then
echo "Playing as guest..."
echo $'\377\375\042\377\373\001'
bash -c "./run.sh"
elif echo $command | grep -Eq '^([Ee]|\033)'; then
echo "Goodbye"
exit 0
else
menu
fi
}
multiplayer()
{
# Get client ID
USER_ID="${NCAT_REMOTE_ADDR}_${NCAT_REMOTE_PORT}"
INPUT_FILE="input.txt"
SCREEN_FILE="${USER_ID}.txt"
# Set telnet char mode
echo $'\377\375\042\377\373\001'
while true; do
if read -n 1 -t 0.01 char; then
echo "${USER_ID} ${char}" >> $INPUT_FILE
fi
if [ -f $SCREEN_FILE ]; then
printf "\033[2J"
cat $SCREEN_FILE
fi
sleep 0.01
done
}
menu