Add new rules for tag recommendation. - 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 91853d2295bf4cef544560b8b25dde1868962c04 DIR parent 147154e206079ffb4d2bf17717d857ac5222a1b6 HTML Author: Annna Robert-Houdin <annna@bitreich.org> Date: Mon, 8 Aug 2022 18:10:40 +0200 Add new rules for tag recommendation. Thanks mkf for finding this. Diffstat: M annna-message-common | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) --- DIR diff --git a/annna-message-common b/annna-message-common @@ -29,12 +29,11 @@ regeximatch() { printf '%s' "$1" | grep -i -E -q "$2" } -printf "%s %s %s %s\n" "${0##*/}" "${channel}" "${user}" "${text}" +#printf "%s %s %s %s\n" "${0##*/}" "${channel}" "${user}" "${text}" -set -x [ "$user" = "${ircuser}" ] && exit 0 -set +x +uriexpansion=0 case "${text}" in *\#nospoil*) ;; @@ -82,10 +81,12 @@ case "${text}" in ;; *Gunther*|*GUNTHER*|*Günther*) annna-say -s "${server}" -c "${channel}" "Oh Günther! ❤ ❤ ❤ ${urititle}" + uriexpansion=1 ;; *\|\ Cloudflare*) annna-say -s "${server}" -c "${channel}" "Mind your own business! We got clownflared: gopher://bitreich.org/0/ascii/clownflare.vt" titleend=1 + uriexpansion=1 ;; esac @@ -204,6 +205,7 @@ case "${text}" in [ -n "${suri}" ] && outputstr="${outputstr} screen: ${suri} ;" [ -n "${sturi}" ] && outputstr="${outputstr} subtitles: ${sturi} ;" annna-say -s "${server}" -c "${channel}" "${outputstr}" + uriexpansion=1 fi rm -f "${tmpf}" ;; @@ -1074,7 +1076,6 @@ case "${text}" in ;; esac -set -x printf '%s' "$text" | awk -v taglimit="$printnhashtags" ' $0 !~ /#nospoil/ { while (match($0, /#[^# /"'\'',?!;$\001]+/)) { @@ -1090,14 +1091,19 @@ do then annna-say -s "${server}" -c "${channel}" "${tagline% *}: ${tagline#* }" else - didyoumean="$(annna-meme-recommend "${tag}")" - if [ -n "${didyoumean}" ]; + # 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 ]; 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 done -set +x case "${text}" in *\#nospoil*)