Adding #rich-tesla-professor tag. - annna - Annna the nice friendly bot. | |
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
--- | |
commit 5686e1821c5d41273285bea49afc9f8018fda908 | |
parent da438992f6895dfec46e39bbb2fb409ed8c97c7f | |
Author: Annna Robert-Houdin <[email protected]> | |
Date: Mon, 20 Feb 2023 18:55:16 +0100 | |
Adding #rich-tesla-professor tag. | |
Diffstat: | |
M annna-message-common | 43 ++++++++++++++++++++++++++++-… | |
M modules/hashtags/hashtags.txt | 1 + | |
A revpointer | 72 +++++++++++++++++++++++++++++… | |
3 files changed, 113 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/annna-message-common b/annna-message-common | |
@@ -1159,7 +1159,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) | |
@@ -1169,14 +1169,22 @@ $0 !~ /#nospoil/ { | |
}' | while read -r tag; | |
do | |
[ "${tag}" == "#expand" ] && continue | |
+ | |
+ set -x | |
origtag="${tag}" | |
+ pointer=0 | |
+ revpointer=0 | |
case "${tag}" in | |
"*"*) | |
tag="#$(printf "%s\n" "${tag}" | sed "s,^[\*]*,,")" | |
- pointer=1;; | |
+ pointer=1 | |
+ ;; | |
+ "&"*) | |
+ tag="#$(printf "%s\n" "${tag}" | sed "s,^[\&]*,,")" | |
+ revpointer=1 | |
+ ;; | |
*) | |
- pointer=0;; | |
esac | |
if tagline="$(grep "${tag} " "${hashtagfile}")"; | |
@@ -1212,6 +1220,35 @@ do | |
outfile="$(basename "${outpath}")" | |
annna-say -s "${server}" -c "${channel… | |
fi | |
+ elif [ $revpointer -eq 1 ]; | |
+ then | |
+ inpath="/br/gopher/memecache/${tagline##*/}" | |
+ [ ! -f "${inpath}" ] && exit 0 | |
+ | |
+ outfile="${tag#\#}.jpg" | |
+ # pointy pointers | |
+ outpath="$(printf "%s\n" "${origtag}" \ | |
+ | sed 's,\&,&\n,g' \ | |
+ | grep "^&" \ | |
+ | while read -r asterisk; | |
+ do | |
+ outfile="&${outfile}" | |
+ outpath="/br/gopher/memecache/filter/$… | |
+ printf "%s\n" "${outpath}" | |
+ if [ -e "${outpath}" ]; | |
+ then | |
+ inpath="${outpath}"; | |
+ continue | |
+ fi | |
+ revpointer "${inpath}" "${outpath}" 2>… | |
+ inpath="${outpath}"; | |
+ done | tail -n 1)" | |
+ | |
+ if [ -e "${outpath}" ]; | |
+ then | |
+ outfile="$(basename "${outpath}")" | |
+ annna-say -s "${server}" -c "${channel… | |
+ fi | |
else | |
annna-say -s "${server}" -c "${channel}" "${ta… | |
fi | |
diff --git a/modules/hashtags/hashtags.txt b/modules/hashtags/hashtags.txt | |
@@ -11561,6 +11561,7 @@ | |
#rice-krispies gophers://bitreich.org/9/memecache/rice-krispies.mp4 | |
#ricebowl gophers://bitreich.org/I/memecache/ricebowl.jpg | |
#rich-lamborghini-doctor gophers://bitreich.org/I/memecache/rich-lamborghini-d… | |
+#rich-tesla-professor gophers://bitreich.org/I/memecache/rich-tesla-professor.… | |
#richness gophers://bitreich.org/I/memecache/richness.png | |
#ridebike gophers://bitreich.org/I/memecache/ridebike.jpg | |
#right gophers://bitreich.org/9/memecache/right.mkv | |
diff --git a/revpointer b/revpointer | |
@@ -0,0 +1,72 @@ | |
+#!/bin/sh | |
+ | |
+die() { | |
+ [ -n "$1" ] && printf '%s\n' "$1" >&2 | |
+ exit 1 | |
+} | |
+ | |
+[ $# -ne 2 ] && die "usage: ${0##*/} <file> <outimagefile>" | |
+ | |
+mimetype="$(file -ib "$1")" | |
+rminfile=0 | |
+case "$mimetype" in | |
+video/*) | |
+ in="$(mktemp -u tmp.XXXXXXXX.jpg)" | |
+ ffmpeg -i "$1" -frames:v 1 "$in" | |
+ if [ $? -gt 0 ]; | |
+ then | |
+ [ -e "${in}" ] && rm -f "${in}" | |
+ die | |
+ fi | |
+ rminfile=1 | |
+ ;; | |
+image/png*) | |
+ # imagemagick text draw on png files is broken, | |
+ # tested on gentoo imagemagick version 7.1.0-48 | |
+ in="$(mktemp tmp.XXXXXXXX.jpg)" | |
+ convert "$1" "$in" | |
+ if [ $? -gt 0 ]; | |
+ then | |
+ rm "${in}" | |
+ die | |
+ fi | |
+ rminfile=1 | |
+ ;; | |
+image/*) | |
+ in="$1" | |
+ ;; | |
+*) | |
+ die "file type '${mimetype}' not supported" | |
+ ;; | |
+esac | |
+ | |
+n="${1##*/}" | |
+n="${n%.*}" | |
+tmp="$(mktemp tmp.XXXXXXXXX.jpg)" | |
+convert \ | |
+ \( \ | |
+ +append \ | |
+ "${in}" \ | |
+ /home/annna/bin/modules/filter-media/revpointer.jpg \ | |
+ -resize x500 \ | |
+ \) \ | |
+ -pointsize 50 -fill white \ | |
+ -stroke black -strokewidth 1 \ | |
+ -gravity southwest \ | |
+ -gravity northeast \ | |
+ -draw "text -422,+440 '&${n}'" \ | |
+ "$tmp" | |
+# -draw "text +10,+10 '${n}'" \ | |
+exitcode=$? | |
+if [ $exitcode -eq 0 ]; | |
+then | |
+ cp "${tmp}" "$2" | |
+ chmod o+r "$2" | |
+fi | |
+ | |
+# cleanup | |
+rm "${tmp}" | |
+[ $rminfile -eq 1 ] && rm "${in}" | |
+ | |
+exit $exitcode | |
+ |