automt: some fixes

This commit is contained in:
cora 2020-11-26 13:43:55 +01:00 committed by Schmappie Eldress
parent b4da45df12
commit 75e85290cb

23
automt
View File

@ -1,5 +1,6 @@
#!/bin/sh
if [ $# -lt 1 ]; then echo "usage: automt [ menu ] || [server username password]"; exit 1; fi
tomenu=1
if [ $# -lt 1 ]; then tomenu=0; fi
pwf=~/.mtpw
srv=$1
prt=30000
@ -10,7 +11,7 @@ chatlogdir=~/.wschat
mtpid=0
mtpath=$(dirname $0)
dbg=1
if [ ! -z $4 ]; then dbg=0; fi
if [ "$(echo $*|grep debug)" != "" ] || [ ! -z $4 ]; then dbg=0; fi
mkdir -p $chatlogdir
if [ -f $pwf ]; then pas=$(cat $pwf); fi
if [ "$(echo $srv|grep ':')" != "" ]; then
@ -24,11 +25,12 @@ check_host() {
}
mt=$mtpath/bin/minetest
amt="$mt --go --address $srv --port $prt --name $usr --password $passwd"
if [ "$1" = "menu" ]; then mmt=$mt; else mmt=$amt; fi
startmt() {
$mmt 2>&1|sed 's/[\x01-\x1F\x7F]//g' | while read l; do
if [ "$1" = "menu" ]; then mmt=$mt
else mmt="$mt --go --address $srv --port $prt --name $usr --password $passwd"; fi
$mmt 2>&1| while read k; do
l=$(echo $k|sed "s,\x1B\[[0-9;]*[a-zA-Z],_,g")
if [ "$(echo $l |grep '\[cchat\]\|\[hignore\]')" != "" ]; then
srvstr=$(echo $l|cut -d ' ' -f 5)
lgstr=$(echo $l|sed 's/ACTION\[Main\]://'|sed "s/ \[cchat\] //;s/$srvstr//")
@ -50,14 +52,16 @@ startmt() {
if [ $dbg -eq 0 ]; then echo $l; fi
done
}
if [ $tomenu -eq 0 ]; then
startmt menu
else
while true; do
if [ -f /tmp/$(whoami)-wsxt ]; then
rm /tmp/$(whoami)-wsxt
rm -f /tmp/$(whoami)-wsxt
break
fi
if [ -f /tmp/$(whoami)-wsxmen ]; then
rm /tmp/$(whoami)-wsxmen
rm -f /tmp/$(whoami)-wsxmen
startmt menu
break
fi
@ -67,4 +71,5 @@ while true; do
mtpid=$!
fi
sleep 1
done
done
fi