commit f5ce40be79d42124daaf7119d7b04f443187c9be
parent dce550f4a61473facc61fa23617b6e0bcdccf5a8
Author: hhvn <hayden@haydenvh.com>
Date: Mon, 1 Feb 2021 09:19:03 +0000
bin/interface.sh: allow cancelling of message (without disconnecting)
Diffstat:
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/bin/interface.sh b/bin/interface.sh
@@ -1,5 +1,7 @@
#!/bin/sh
+. $cwd/include/userinfo.sh
+
k=$(tput setaf $key___colour)
s=$(tput sgr0)
@@ -91,7 +93,7 @@ menu_list(){
o) break ;;
r)
[ "$arg" = "" ] && prompt "id" arg
- echo "$arg" | grep '.' >/dev/null {
+ echo "$arg" | grep '.' >/dev/null && {
arg="$arg.0"
}
grep "^${arg%%.*} ${arg##*.}" < $datadir/boards/$board/list >/dev/null && {
@@ -102,9 +104,19 @@ menu_list(){
;;
n)
[ "$arg" = "" ] && prompt "Subject" subject || subject="$arg"
- info "Type ctrl+d to save the post"
+ info "Type ctrl+d to end the post"
file="$datadir/boards/$board/$(echo "$(find $datadir/boards/$board/ -type f | wc -l) + 1" | bc).post"
cat > $file
+ save=""
+ while [ "$save" != "y" ] && [ "$save" != "n" ]
+ do
+ prompt "Save mesage (${k}y${s}/${k}n${s})" save
+ done
+ [ "$save" = "n" ] && {
+ info "didn't save message"
+ anykey
+ break
+ }
awk -v "data=1 0 $(date +%d-%b-%Y) $user $subject $(basename $file)" -F" " \
'BEGIN {print data}; $4 != "root" {print $1 + 1 "\t" $2 "\t" $3 "\t" $4 "\t" $5 "\t" $6 "\t" $7}' \
< $datadir/boards/$board/list > $datadir/boards/$board/list.new
@@ -169,8 +181,17 @@ menu_read(){
ofile="$file"
file="$datadir/boards/$board/$(echo "$(find $datadir/boards/$board/ -type f | wc -l) + 1" | bc).post"
cat > $file
+ save=""
+ while [ "$save" != "y" ] && [ "$save" != "n" ]
+ do
+ prompt "Save mesage (${k}y${s}/${k}n${s})" save
+ done
+ [ "$save" = "n" ] && {
+ info "didn't save message"
+ anykey
+ break
+ }
lnum=$(echo "$(awk -v "file=$(echo "$ofile" | sed 's/ .*//')" -F" " '$6 == file' < $datadir/boards/$board/list | wc -l) - 1" | bc)
- anykey
awk -v "n=1" -v "file=$(basename "$file")" -v "lnum=$lnum" -v "user=$user" -v "date=$(date +%d-%b-%Y)" -v "ofile=$(echo "$ofile" | sed 's/ .*//')" -F" " '
$6 == ofile && $2 != lnum {print; n = $1}
$6 == ofile && $2 == lnum {print; print n "\t" lnum + 1 "\t" date "\t" user "\t_\t" ofile "\t" file}