Add #expand feature for memes. - 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 f6e79e5c8ee01fb3feb8f279e8f05419b77e2935 DIR parent f368378e0c7a575d13f0dd1c19c6e640c0418ad4 HTML Author: Annna Robert-Houdin <annna@bitreich.org> Date: Tue, 16 Aug 2022 13:11:09 +0200 Add #expand feature for memes. Diffstat: M annna-message-common | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) --- DIR diff --git a/annna-message-common b/annna-message-common @@ -35,10 +35,14 @@ regeximatch() { uriexpansion=0 nospoil=0 +doexpand=0 case "${text}" in *\#nospoil*) nospoil=1 ;; +*\#expand*) + doexpand=1 + ;; *::*::*) query=${text#**::} query=${query%%::*} annna-say -s "${server}" -c "${channel}" "$(dalle-gen-emoji "${query}")" & @@ -1089,6 +1093,8 @@ $0 !~ /#nospoil/ { } }' | while read -r tag; do + [ "${tag}" == "#expand" ] && continue + if tagline="$(grep "${tag} " "${hashtagfile}")"; then if [ $nospoil -eq 0 ]; @@ -1096,15 +1102,16 @@ do annna-say -s "${server}" -c "${channel}" "${tagline% *}: ${tagline#* }" fi else - # Do not recommend memes in case we got some URI expansion and if unknown - # tag is less than four utf8 chars long. - taglength=$(utf8expr length "${tag}") - if [ $uriexpansion -eq 0 -a $taglength -gt 3 -a $nospoil -eq 0 ]; + if [ $doexpand -eq 1 ]; then - didyoumean="$(annna-meme-recommend "${tag}")" - if [ -n "${didyoumean}" ]; + taglength=$(utf8expr length "${tag}") + if [ $uriexpansion -eq 0 -a $taglength -gt 3 ]; then - annna-say -c "${server}" -c "${channel}" "Did you mean: ${didyoumean}?" + didyoumean="$(annna-meme-recommend "${tag}")" + if [ -n "${didyoumean}" ]; + then + annna-say -c "${server}" -c "${channel}" "Did you mean: ${didyoumean}?" + fi fi fi fi