add meme pointer support - annna - Annna the nice friendly bot.
 (HTM) git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
       ---
 (DIR) commit f008d349f0a8b0350b482dc0f48e5a24c7f5c2ce
 (DIR) parent da84f9338c88f1cdc665237933a5b6025eb3adc0
 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Fri, 17 Feb 2023 10:38:22 +0100
       
       add meme pointer support
       
       Signed-off-by: Annna Robert-Houdin <annna@bitreich.org>
       
       Diffstat:
         M annna-message-common                |      23 +++++++++++++++++++++--
         A pointer                             |      38 +++++++++++++++++++++++++++++++
       
       2 files changed, 59 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/annna-message-common b/annna-message-common
       @@ -1147,7 +1147,7 @@ esac
        
        printf '%s' "$text" | awk -v taglimit="$printnhashtags" '
        $0 !~ /#nospoil/ {
       -        while (match($0, /#[^# /"'\'',?!;$\001]+/)) {
       +        while (match($0, /[#*][^#^* /"'\'',?!;$\001]+/)) {
                        tag = substr($0, RSTART, RLENGTH)
                        $0 = substr($0, RSTART + RLENGTH)
                        sub(/[.]*$/, "", tag)
       @@ -1157,12 +1157,31 @@ $0 !~ /#nospoil/ {
        }' | while read -r tag;
        do
                [ "${tag}" == "#expand" ] && continue
       +        case "${tag}" in
       +        "*"*)
       +                tag="#${tag#\*}"
       +                pointer=1;;
       +        *)
       +                pointer=0;;
       +        esac
        
                if tagline="$(grep "${tag} " "${hashtagfile}")";
                then
                        if [ $nospoil -eq 0 ];
                        then
       -                        annna-say -s "${server}" -c "${channel}" "${tagline% *}: ${tagline#* }"
       +                        if [ $pointer -eq 1 ];
       +                        then
       +                                outfile="*${tag#\#}.jpg"
       +                                outpath="/br/gopher/memecache/filter/${outfile}"
       +                                inpath="/br/gopher/memecache/${tagline##*/}"
       +                                [ ! -f "${inpath}" ] && exit 0
       +                                if pointer "${inpath}" "${outpath}" 2>&1 >/dev/null;
       +                                then
       +                                        annna-say -s "${server}" -c "${channel}" "*${tag#\#}: gophers://bitreich.org/9/memecache/filter/${outfile}"
       +                                fi
       +                        else
       +                                annna-say -s "${server}" -c "${channel}" "${tagline% *}: ${tagline#* }"
       +                        fi
                        fi
                else
                        if [ $doexpand -eq 1 ];
 (DIR) diff --git a/pointer b/pointer
       @@ -0,0 +1,38 @@
       +#!/bin/sh
       +
       +die() {
       +        printf '%s\n' "$1" >&2
       +        exit 1
       +}
       +
       +if test $# -ne 2; then
       +        die "usage: ${0##*/} <file> <outimagefile>"
       +fi
       +
       +mimetype="$(file -ib "$1")"
       +case "$mimetype" in
       +        video/*)
       +                in="$(mktemp).jpg"
       +                ffmpeg -i "$1" -frames:v 1 "$in";;
       +        image/*)
       +                in="$1";;
       +        *)
       +                die "file type '${mimetype}' not supported";;
       +esac
       +
       +n="${1##*/}"
       +n="${n%.*}"
       +convert \
       +        \( \
       +                +append \
       +                "${in}" \
       +                /home/annna/bin/modules/filter-media/pointer.jpg \
       +                -resize x500 \
       +        \) \
       +        -pointsize 50 -fill white \
       +        -stroke black -strokewidth 1 \
       +        -gravity southwest \
       +        -draw "text +10,+10 '${n}'" \
       +        -gravity northeast \
       +        -draw "text -422,+20 '*${n}'" \
       +        "$2"