Add random #tag selection. - 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 b58ec95b06148f41116103745fd8dc7ba0ff9c24 DIR parent d3bbf6476945cd43149a90c29b8ef56990e7db87 HTML Author: Annna Robert-Houdin <annna@bitreich.org> Date: Sun, 10 Feb 2019 17:24:25 +0100 Add random #tag selection. Diffstat: M annna-start-services | 66 +++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 20 deletions(-) --- DIR diff --git a/annna-start-services b/annna-start-services @@ -276,28 +276,54 @@ then continue; fi - tagname="" - taguri="" - for tag in ${hashtags}; - do - [ -z "${tagname}" ] && tagname="${tag}" && continue - taguri="${tag}" + randomtag=0 + case "${text}" in + *\#nospoil*) + ;; + *\#tag[^a-zA-Z]*) + randomtag=1 + ;; + *\#tag) + randomtag=1 + ;; + esac - case "${text}" in - *\#nospoil*) - break; - ;; - *${tagname}[^a-zA-Z]*) - annna-say -c "#bitreich-en" "${tagname}: ${taguri}" - break; - ;; - *${tagname}) - annna-say -c "#bitreich-en" "${tagname}: ${taguri}" - break; - ;; - esac + if [ $randomtag -eq 1 ]; + then + rtag="$(printf "%s\n" "${hashtags}" | shuf -n 1)" tagname="" - done + taguri="" + for tag in ${rtag}; + do + [ -z "${tagname}" ] && tagname="${tag}" && continue + taguri="${tag}" + done + + annna-say -c "#bitreich-en" "${tagname}: ${taguri}" + else + tagname="" + taguri="" + for tag in ${hashtags}; + do + [ -z "${tagname}" ] && tagname="${tag}" && continue + taguri="${tag}" + + case "${text}" in + *\#nospoil*) + break; + ;; + *${tagname}[^a-zA-Z]*) + annna-say -c "#bitreich-en" "${tagname}: ${taguri}" + break; + ;; + *${tagname}) + annna-say -c "#bitreich-en" "${tagname}: ${taguri}" + break; + ;; + esac + tagname="" + done + fi ismember=0 for member in $brmembers;