make sure tagline is non-zero and other minor awk tweaks - 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 14fd160e2d5b4e9246327648bd295e31ceaec5fd
(DIR) parent 99c08878d8c6c5460b7615776bde2bda054ca444
(HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Fri, 13 Nov 2020 16:48:49 +0100
make sure tagline is non-zero and other minor awk tweaks
Signed-off-by: Annna Robert-Houdin <annna@bitreich.org>
Diffstat:
M annna-start-services | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
---
(DIR) diff --git a/annna-start-services b/annna-start-services
@@ -658,24 +658,21 @@ annna_common() {
done
else
printf '%s' "$text" | awk -v taglimit="$printnhashtags" '
- {
- if ($0 ~ /#/ && $0 !~ /#nospoil/) {
- for (i = 1; i <= NF; i++) {
- if (match($i, /#[A-z0-9\+-]*/)) {
- tags[j++] = substr($i, RSTART, RLENGTH)
- }
- }
- }
+ $0 ~ /#/ && $0 !~ /#nospoil/ {
+ for (i = 1; i <= NF; i++)
+ if (match($i, /#[A-z0-9\+-]*/))
+ tags[j++] = substr($i, RSTART, RLENGTH)
}
END {
- for (tag in tags) {
+ for (tag in tags)
if (k++ < taglimit)
print tags[tag]
- }
}' | while read -r tag;
do
- tagline="$(grep "${tag} " "${hashtagfile}")"
- annna-say -c "${channel}" "${tagline% *}: ${tagline#* }"
+ if tagline="$(grep "${tag} " "${hashtagfile}")";
+ then
+ annna-say -c "${channel}" "${tagline% *}: ${tagline#* }"
+ fi
done
fi