URI: 
       use an empty case entry instead of checking [ -n "$x" ] before it - 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 9a192ffcabc9b67d60a1db9843ad8100397a6db4
   DIR parent cb97a0dd368eed35d9db94ffdc0c577788dfe168
  HTML Author: Josuah Demangeon <me@josuah.net>
       Date:   Sat,  2 Jul 2022 13:57:23 +0200
       
       use an empty case entry instead of checking [ -n "$x" ] before it
       
       This helps with flattening the script:
       
       before:
       
               if [ -n "$x" ]
               then
                       case $x in
                       "content") ... ;;
                       "content") ... ;;
                       esac
               fi
       
       after
       
               case $x in
               "") ;;
               "content") ... ;;
               "content") ... ;;
               esac
       
       The patch is more readable when ignoring spaces: git diff -w
       
       Signed-off-by: Annna Robert-Houdin <annna@bitreich.org>
       
       Diffstat:
         M annna-message-common                |     271 +++++++++++++++----------------
       
       1 file changed, 135 insertions(+), 136 deletions(-)
       ---
   DIR diff --git a/annna-message-common b/annna-message-common
       @@ -33,8 +33,6 @@ regeximatch() {
        
        [ "$user" = "${botname}" ] && exit 0
        
       -uri="$(printf "%s\n" "${text}" \
       -        | sed -n '/.*\(https\{0,1\}:\/\/[^ ]\{1,\}\).*/s//\1/p')"
        case "${text}" in
        *\#nospoil*)
                ;;
       @@ -42,160 +40,161 @@ case "${text}" in
                query=${text#**::} query=${query%%::*}
                annna-say -s "${server}" -c "${channel}" "$(dalle-gen-emoji "${query}")" &
                ;;
       -*)
       -        if [ -n "${uri}" ]
       -        then
       -                tmpf=$(mktemp)
       -                fetch-uri "${uri}" > "${tmpf}"
       -                urititle="$(grabtitle < "${tmpf}")"
       +*http*://*)
       +        uri="$(printf "%s\n" "${text}" \
       +                | sed -n '/.*\(https\{0,1\}:\/\/[^ ]\{1,\}\).*/s//\1/p')"
        
       -                # Set below and annna will concatenate at the end.
       -                # Subtitle URI.
       -                sturi=""
       -                # Replacement URI.
       -                nuri=""
       -                # Replacement URI display string.
       -                nuris=""
       -                # html2text content.
       -                curi=""
       -                # Set to 0, if some URI content should be shown.
       -                nocuri=1
       -                # Screenshot.
       -                suri=""
       +        tmpf=$(mktemp)
       +        fetch-uri "${uri}" > "${tmpf}"
       +        urititle="$(grabtitle < "${tmpf}")"
        
       -                # titleend=1 will not output any further.
       -                titleend=0
       -                outputstr=""
       +        # Set below and annna will concatenate at the end.
       +        # Subtitle URI.
       +        sturi=""
       +        # Replacement URI.
       +        nuri=""
       +        # Replacement URI display string.
       +        nuris=""
       +        # html2text content.
       +        curi=""
       +        # Set to 0, if some URI content should be shown.
       +        nocuri=1
       +        # Screenshot.
       +        suri=""
        
       -                if [ -n "$urititle" ];
       -                then
       -                        case "${urititle}" in
       -                        *Gunther*|*GUNTHER*|*Günther*)
       -                                annna-say -s "${server}" -c "${channel}" "Oh Günther! ❤  ❤  ❤  ${urititle}"
       -                                ;;
       -                        *\|\ Cloudflare*)
       -                                annna-say -s "${server}" -c "${channel}" "Mind your own business! We got clownflared: gopher://bitreich.org/0/ascii/clownflare.vt"
       -                                titleend=1
       -                                ;;
       -                        esac
       -                fi
       +        # titleend=1 will not output any further.
       +        titleend=0
       +        outputstr=""
        
       -                case "${uri}" in
       -                *github.com/*/blob/*)
       -                        urltitle=""
       -                        nuris="$(printf '%s' "${uri}" | sed 's/blob/raw/')"
       -                        nocuri=0
       -                        ;;
       +        case "${urititle}" in
       +        "")
       +                ;;
       +        *Gunther*|*GUNTHER*|*Günther*)
       +                annna-say -s "${server}" -c "${channel}" "Oh Günther! ❤  ❤  ❤  ${urititle}"
       +                ;;
       +        *\|\ Cloudflare*)
       +                annna-say -s "${server}" -c "${channel}" "Mind your own business! We got clownflared: gopher://bitreich.org/0/ascii/clownflare.vt"
       +                titleend=1
       +                ;;
       +        esac
        
       -                *imgur.com/*)
       -                        nuris="$(youtube-dl -g "${uri}")"
       -                        if [ $? -gt 0 ];
       -                        then
       -                                nuris=""
       -                        fi
       -                        ;;
       -                *xkcd.com/*)
       -                        nuris="$(xkcd-uri "${uri}")"
       -                        ;;
       -                *imdb.com/title/*)
       -                        movietitle="$(imdb2gopherbay "${uri}" | sed 's, ,+,g')"
       -                        if [ -n "${movietitle}" ];
       -                        then
       -                                nuris="gopher://bay.parazy.de:666/1/q.dcgi?${movietitle}"
       -                        fi
       -                        ;;
       -                *themoviedb.org/movie/*)
       -                        movietitle="$(themoviedb2gopherbay "${uri}" | sed 's, ,+,g')"
       -                        if [ -n "${movietitle}" ];
       -                        then
       -                                nuris="gopher://bay.parazy.de:666/1/q.dcgi?${movietitle}"
       -                        fi
       -                        ;;
       -                *lichess.org/????????|*lichess.org/????????/|*lichess.org/????????/black|*lichess.org/????????/white)
       -                        nuris="$(printf "%s\n" "${uri}" \
       -                                | sed 's,https://lichess.org\(/[^ ]*\)$,\1,; s,^/\([^/]*\)/black$,/black/\1,; s,/white,,; s,\(.*\),https://lichess1.org/game/export/gif\1.gif,;')"
       -                        ;;
       -                *www.npr.org/*)
       +        case "${uri}" in
       +        "")
       +                ;;
       +        *github.com/*/blob/*)
       +                urltitle=""
       +                nuris="$(printf '%s' "${uri}" | sed 's/blob/raw/')"
       +                nocuri=0
       +                ;;
       +
       +        *imgur.com/*)
       +                nuris="$(youtube-dl -g "${uri}")"
       +                if [ $? -gt 0 ];
       +                then
       +                        nuris=""
       +                fi
       +                ;;
       +        *xkcd.com/*)
       +                nuris="$(xkcd-uri "${uri}")"
       +                ;;
       +        *imdb.com/title/*)
       +                movietitle="$(imdb2gopherbay "${uri}" | sed 's, ,+,g')"
       +                if [ -n "${movietitle}" ];
       +                then
       +                        nuris="gopher://bay.parazy.de:666/1/q.dcgi?${movietitle}"
       +                fi
       +                ;;
       +        *themoviedb.org/movie/*)
       +                movietitle="$(themoviedb2gopherbay "${uri}" | sed 's, ,+,g')"
       +                if [ -n "${movietitle}" ];
       +                then
       +                        nuris="gopher://bay.parazy.de:666/1/q.dcgi?${movietitle}"
       +                fi
       +                ;;
       +        *lichess.org/????????|*lichess.org/????????/|*lichess.org/????????/black|*lichess.org/????????/white)
       +                nuris="$(printf "%s\n" "${uri}" \
       +                        | sed 's,https://lichess.org\(/[^ ]*\)$,\1,; s,^/\([^/]*\)/black$,/black/\1,; s,/white,,; s,\(.*\),https://lichess1.org/game/export/gif\1.gif,;')"
       +                ;;
       +        *www.npr.org/*)
       +                post="$(printf '%s\n' "${uri}" | cut -d / -f 7)"
       +                if [ -n "${post}" ];
       +                then
       +                        nuri="https://text.npr.org/s.php?sId=${post}"
       +                        nuris="text only: ${nuri}"
       +                fi
       +                ;;
       +        *www.reddit.com*)
       +                nuri="$(printf '%s\n' "${uri}" | sed "s;www.reddit.com;old.reddit.com;")"
       +                nuris="old.reddit: ${nuri}"
       +                fetch-uri "${nuri}" > "${tmpf}"
       +                if [ -n "${uri#*www.reddit.com/r/*}" ];
       +                then
       +                        subreddit="$(printf '%s\n' "${uri}" | cut -d / -f 5)"
                                post="$(printf '%s\n' "${uri}" | cut -d / -f 7)"
                                if [ -n "${post}" ];
                                then
       -                                nuri="https://text.npr.org/s.php?sId=${post}"
       -                                nuris="text only: ${nuri}"
       +                                guri="gopher://gopherddit.com/1/cgi-bin/reddit.cgi?view&${post}&${subreddit}&10"
       +                        else
       +                                guri="gopher://gopherddit.com/1/cgi-bin/reddit.cgi?menu&${subreddit}&10"
                                fi
       -                        ;;
       -                *www.reddit.com*)
       -                        nuri="$(printf '%s\n' "${uri}" | sed "s;www.reddit.com;old.reddit.com;")"
       -                        nuris="old.reddit: ${nuri}"
       -                        fetch-uri "${nuri}" > "${tmpf}"
       -                        if [ -n "${uri#*www.reddit.com/r/*}" ];
       -                        then
       -                                subreddit="$(printf '%s\n' "${uri}" | cut -d / -f 5)"
       -                                post="$(printf '%s\n' "${uri}" | cut -d / -f 7)"
       -                                if [ -n "${post}" ];
       -                                then
       -                                        guri="gopher://gopherddit.com/1/cgi-bin/reddit.cgi?view&${post}&${subreddit}&10"
       -                                else
       -                                        guri="gopher://gopherddit.com/1/cgi-bin/reddit.cgi?menu&${subreddit}&10"
       -                                fi
       -                                nuris="${nuri} ; gopherdit: ${guri}"
       -                        fi
       -                        nocuri=0
       -                        ;;
       -                *twitter.com*)
       -                        ninstance="$(nitter-instance | sed 's,\.,\\\.,g')"
       -                        nuri="$(printf "%s\n" "${uri}" | sed "s;\(mobile\.\)\{0,1\}twitter\.com;${ninstance};")"
       +                        nuris="${nuri} ; gopherdit: ${guri}"
       +                fi
       +                nocuri=0
       +                ;;
       +        *twitter.com*)
       +                ninstance="$(nitter-instance | sed 's,\.,\\\.,g')"
       +                nuri="$(printf "%s\n" "${uri}" | sed "s;\(mobile\.\)\{0,1\}twitter\.com;${ninstance};")"
       +                fetch-uri "${nuri}" > "${tmpf}"
       +                urititle="$(curl-grabtitle "${nuri}")"
       +                suri="$(screenshot-paste "${nuri}")"
       +                nuris="nitter: ${nuri}"
       +                nocuri=0
       +                ;;
       +        *en.wikipedia.org/wiki*)
       +                if ! regeximatch "$uri" '\.(jpg,bmp,gif,png,tiff,avi,mp4,webm,mkv,pdf,ps,eps)$';
       +                then
       +                        nuri="$(printf '%s\n' "${uri}" | sed -e "s;.*en.wikipedia.org/wiki;gopher://gopherpedia.com/0;" -e "s;#.*$;;")"
       +                        nuris="$(printf 'gopherpedia: %s\n' "${nuri}")"
                                fetch-uri "${nuri}" > "${tmpf}"
       -                        urititle="$(curl-grabtitle "${nuri}")"
       -                        suri="$(screenshot-paste "${nuri}")"
       -                        nuris="nitter: ${nuri}"
                                nocuri=0
       -                        ;;
       -                *en.wikipedia.org/wiki*)
       -                        if ! regeximatch "$uri" '\.(jpg,bmp,gif,png,tiff,avi,mp4,webm,mkv,pdf,ps,eps)$';
       -                        then
       -                                nuri="$(printf '%s\n' "${uri}" | sed -e "s;.*en.wikipedia.org/wiki;gopher://gopherpedia.com/0;" -e "s;#.*$;;")"
       -                                nuris="$(printf 'gopherpedia: %s\n' "${nuri}")"
       -                                fetch-uri "${nuri}" > "${tmpf}"
       -                                nocuri=0
       -                        fi
       -                        ;;
       -                *youtube.com/*|*youtu.be/*)
       -                        nuri="https://yewtu.be/${uri#https*://*/}"
       -                        fetch-uri "${nuri}" > "${tmpf}"
       -                        urititle="$(curl-grabtitle "${nuri}")"
       -                        sturi="$(subtitle-paste "${uri}")"
       -                        nuris="invidious: ${nuri}"
       +                fi
       +                ;;
       +        *youtube.com/*|*youtu.be/*)
       +                nuri="https://yewtu.be/${uri#https*://*/}"
       +                fetch-uri "${nuri}" > "${tmpf}"
       +                urititle="$(curl-grabtitle "${nuri}")"
       +                sturi="$(subtitle-paste "${uri}")"
       +                nuris="invidious: ${nuri}"
       +                nocuri=0
       +                ;;
       +        *)
       +                mimetype="$(file -b --mime-type "${tmpf}")"
       +                case "${mimetype}" in
       +                text/*)
                                nocuri=0
                                ;;
       -                *)
       -                        mimetype="$(file -b --mime-type "${tmpf}")"
       -                        case "${mimetype}" in
       -                        text/*)
       -                                nocuri=0
       -                                ;;
       -                        esac
       -                        ;;
                        esac
       +                ;;
       +        esac
        
       -                if [ $titleend -eq 0 ];
       +        if [ $titleend -eq 0 ];
       +        then
       +                if [ $nocuri -eq 0 ];
                        then
       -                        if [ $nocuri -eq 0 ];
       +                        if [ -z "${curi}" ];
                                then
       -                                if [ -z "${curi}" ];
       -                                then
       -                                        curi="$(html2text < "${tmpf}" | /br/bin/bitreich-paste)"
       -                                fi
       -                                outputstr="${outputstr} content: ${curi} ;"
       +                                curi="$(html2text < "${tmpf}" | /br/bin/bitreich-paste)"
                                fi
       -
       -                        [ -n "${nuris}" ] && outputstr="${outputstr} ${nuris} ;"
       -                        [ -n "${urititle}" ] && outputstr="${outputstr} title: ${urititle} ;"
       -                        [ -n "${suri}" ] && outputstr="${outputstr} screen: ${suri} ;"
       -                        [ -n "${sturi}" ] && outputstr="${outputstr} subtitles: ${sturi} ;"
       -                        annna-say -s "${server}" -c "${channel}" "${outputstr}"
       +                        outputstr="${outputstr} content: ${curi} ;"
                        fi
       -                rm -f "${tmpf}"
       +
       +                [ -n "${nuris}" ] && outputstr="${outputstr} ${nuris} ;"
       +                [ -n "${urititle}" ] && outputstr="${outputstr} title: ${urititle} ;"
       +                [ -n "${suri}" ] && outputstr="${outputstr} screen: ${suri} ;"
       +                [ -n "${sturi}" ] && outputstr="${outputstr} subtitles: ${sturi} ;"
       +                annna-say -s "${server}" -c "${channel}" "${outputstr}"
                fi
       +        rm -f "${tmpf}"
                ;;
        esac