merge two if [ "${text}" = "..." ] back to the main case ${text} - annna - Annn… | |
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
--- | |
commit ea1854a310ae05275e392beb53a2ae35bcd36a50 | |
parent 9a192ffcabc9b67d60a1db9843ad8100397a6db4 | |
Author: Josuah Demangeon <[email protected]> | |
Date: Sat, 2 Jul 2022 14:08:18 +0200 | |
merge two if [ "${text}" = "..." ] back to the main case ${text} | |
The randomtag logic is not made a special case anymore: | |
The script still executes the randomtag block, | |
calling shuf (absent from my system) to fetch a random tag: | |
$ sh -x ./annna-message-common server channel user "annna, please meme … | |
[...] | |
+ text=annna, please meme meme meme me. | |
+ [ user = annna ] | |
+ randomtag=2 | |
+ [ 2 -gt 0 ] | |
+ shuf -n 1 | |
./annna-message-common[1003]: shuf: not found | |
+ hashtags | |
+ printf %s\n | |
+ rtag= | |
+ tagname= | |
+ taguri= | |
+ annna-say -s server -c channel : | |
-s server -c channel : | |
+ randomtag=1 | |
[...] | |
Signed-off-by: Annna Robert-Houdin <[email protected]> | |
Diffstat: | |
M annna-message-common | 81 ++++++++++++++---------------… | |
1 file changed, 36 insertions(+), 45 deletions(-) | |
--- | |
diff --git a/annna-message-common b/annna-message-common | |
@@ -975,22 +975,49 @@ case "${text}" in | |
sleep 0.5 | |
annna-say -s "${server}" -c "${user}" "»please help.« gives you this… | |
;; | |
-esac | |
- | |
-randomtag=0 | |
-if [ "${text}" = "${botname}, please meme meme meme me." ]; | |
-then | |
+"${botname}, please meme meme meme me.") | |
randomtag=2 | |
-fi | |
+ while [ $randomtag -gt 0 ]; | |
+ do | |
+ rtag="$(printf "%s\n" "$(hashtags)" | shuf -n 1)" | |
+ tagname="" | |
+ taguri="" | |
+ for tag in ${rtag}; | |
+ do | |
+ [ -z "${tagname}" ] && tagname="${tag}" && continue | |
+ taguri="${tag}" | |
+ done | |
+ | |
+ annna-say -s "${server}" -c "${channel}" "${tagname}: ${taguri… | |
-if [ "${text}" = "${botname}, what's the wheelchair shooter meme again?" ]; | |
-then | |
+ randomtag=$((randomtag - 1)) | |
+ done | |
+ ;; | |
+"${botname}, what's the wheelchair shooter meme again?") | |
tagname="#scrollby" | |
tagline="$(printf "%s\n" "$(hashtags)" | grep "^${tagname} ")" | |
tagname="$(printf "%s\n" "${tagline}" | cut -d ' ' -f 1)" | |
taguri="$(printf "%s\n" "${tagline}" | cut -d ' ' -f 2-)" | |
annna-say -s "${server}" -c "${channel}" "${tagname}: ${taguri}" | |
-fi | |
+ ;; | |
+esac | |
+ | |
+printf '%s' "$text" | awk -v taglimit="$printnhashtags" ' | |
+$0 !~ /#nospoil/ { | |
+ while (match($0, /#[^# "'\'',?!;$\001]+/)) { | |
+ tag = substr($0, RSTART, RLENGTH) | |
+ $0 = substr($0, RSTART + RLENGTH) | |
+ sub(/[.]*$/, "", tag) | |
+ if (!uniq[tag]++ && taglimit-- > 0) | |
+ print tag | |
+ } | |
+}' | while read -r tag; | |
+do | |
+ if tagline="$(grep "${tag} " "${hashtagfile}")"; | |
+ then | |
+ annna-say -s "${server}" -c "${channel}" "${tagline% *}: ${tag… | |
+ fi | |
+done | |
case "${text}" in | |
*\#nospoil*) | |
@@ -1005,42 +1032,6 @@ case "${text}" in | |
;; | |
esac | |
-if [ $randomtag -gt 0 ]; | |
-then | |
- while [ $randomtag -gt 0 ]; | |
- do | |
- rtag="$(printf "%s\n" "$(hashtags)" | shuf -n 1)" | |
- tagname="" | |
- taguri="" | |
- for tag in ${rtag}; | |
- do | |
- [ -z "${tagname}" ] && tagname="${tag}" && continue | |
- taguri="${tag}" | |
- done | |
- | |
- annna-say -s "${server}" -c "${channel}" "${tagname}: ${taguri… | |
- | |
- randomtag=$(($randomtag - 1)) | |
- done | |
-else | |
- printf '%s' "$text" | awk -v taglimit="$printnhashtags" ' | |
- $0 !~ /#nospoil/ { | |
- while (match($0, /#[^# "'\'',?!;$\001]+/)) { | |
- tag = substr($0, RSTART, RLENGTH) | |
- $0 = substr($0, RSTART + RLENGTH) | |
- sub(/[.]*$/, "", tag) | |
- if (!uniq[tag]++ && taglimit-- > 0) | |
- print tag | |
- } | |
- }' | while read -r tag; | |
- do | |
- if tagline="$(grep "${tag} " "${hashtagfile}")"; | |
- then | |
- annna-say -s "${server}" -c "${channel}" "${tagline% *… | |
- fi | |
- done | |
-fi | |
- | |
# Always keep the karma / shame last! | |
case "${text}" in | |
*"-shaming"*) |