Add clippy-say script. - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit b507cf1f5f65b005deaf1a9b91edc5aec8c74fee DIR parent 5348fde77ab4f989ff3a290d6d4880b140ab229e HTML Author: Annna Robert-Houdin <annna@bitreich.org> Date: Sun, 24 May 2020 18:56:57 +0200 Add clippy-say script. Diffstat: A clippy-say | 67 +++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+), 0 deletions(-) --- DIR diff --git a/clippy-say b/clippy-say @@ -0,0 +1,67 @@ +#!/bin/sh + +maxbubblelen=74 +#DST="" +DSTDIR="/br/gopher/paste" +CLIPPYTMPL="/br/gopher/memecache/clippy.vtv" + +speaktext="$@" +speaklen="$(utf8expr length "${speaktext}")" + +cd /tmp +tmpfile="$(mktemp p-XXXXXXXXXXXXX.txt)" +touch "${tmpfile}" + +{ + bubblelen=$(($speaklen + 4)) + if [ $bubblelen -gt $maxbubblelen ]; + then + bubblelen=$maxbubblelen + fi + + printf " " + i=0 + while [ $i -lt $((bubblelen - 2)) ]; + do + printf "_" + i=$(($i + 1)) + done + printf "\n" + + textoffset=1 + bubblecontentlen=$(($bubblelen - 4)) + while [ $speaklen -gt 0 ]; + do + newoffset=$(($textoffset + $bubblecontentlen)) + textsubstr="$(utf8expr substr "$speaktext" $textoffset $bubblecontentlen)" + substrlen="$(utf8expr length "${textsubstr}")" + printf "| %s" "$textsubstr" + while [ $substrlen -le $bubblecontentlen ]; + do + printf " " + substrlen=$(($substrlen + 1)) + done + printf "|\n" + textoffset=$(($newoffset)) + speaklen=$(($speaklen - $substrlen)) + done + + printf " " + i=0 + while [ $i -lt $((bubblelen - 2)) ]; + do + printf "-" + i=$(($i + 1)) + done + printf "\n" + + tail -n+4 "${CLIPPYTMPL}" +} > $tmpfile + +mv $tmpfile $DSTDIR +chmod g+rw $DSTDIR/$tmpfile +chgrp bitreich $DSTDIR/$tmpfile + +name="$(basename $tmpfile)" +printf "gopher://bitreich.org/0/p/%s\n" "$name" +