Add new rules for tag recommendation. - annna - Annna the nice friendly bot. | |
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
--- | |
commit 91853d2295bf4cef544560b8b25dde1868962c04 | |
parent 147154e206079ffb4d2bf17717d857ac5222a1b6 | |
Author: Annna Robert-Houdin <[email protected]> | |
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(-) | |
--- | |
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! ❤ �… | |
+ uriexpansion=1 | |
;; | |
*\|\ Cloudflare*) | |
annna-say -s "${server}" -c "${channel}" "Mind your own busine… | |
titleend=1 | |
+ uriexpansion=1 | |
;; | |
esac | |
@@ -204,6 +205,7 @@ case "${text}" in | |
[ -n "${suri}" ] && outputstr="${outputstr} screen: ${suri} ;" | |
[ -n "${sturi}" ] && outputstr="${outputstr} subtitles: ${stur… | |
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% *}: ${tag… | |
else | |
- didyoumean="$(annna-meme-recommend "${tag}")" | |
- if [ -n "${didyoumean}" ]; | |
+ # Do not recommend memes in case we got some URI expansion and… | |
+ # 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="$(annna-meme-recommend "${tag}")" | |
+ if [ -n "${didyoumean}" ]; | |
+ then | |
+ annna-say -c "${server}" -c "${channel}" "Did … | |
+ fi | |
fi | |
fi | |
done | |
-set +x | |
case "${text}" in | |
*\#nospoil*) |