URI: 
       annna-message-common - 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
       ---
       annna-message-common (54865B)
       ---
            1 #!/bin/bash
            2 
            3 [ "${IRC_CMD_USER}" = "${IRC_USER}" ] && exit 0
            4 [ -z "${IRC_PRIVMSG_TEXT}" ] && exit 0
            5 [ ! "$IRC_CMD" = "PRIVMSG" ] && exit 1
            6 
            7 export PATH="$PATH:/br/bin"
            8 
            9 annnasumerian="𒈹"
           10 annnabirthday="1989-05-18"
           11 hashtagfile="${ANNNA_MODBASE}/hashtags/hashtags.txt"
           12 idontcaredb="${ANNNA_MODBASE}/i-dont-care/i-dont-care.txt"
           13 printnhashtags=2
           14 brmembers="__20h__ Evil_Bob chripo posativ quinq stateless solene josuah parazyd bin KatolaZ adc Athas ROYGBYTE"
           15 referees="__20h__"
           16 ignorednicks="eidolon"
           17 linkbrotherchannels="#bitreich-meme"
           18 # Flag, if some expansion of some URI happened.
           19 uriexpansion=0
           20 # Do not spoil at all.
           21 nospoil=0
           22 # Enforce spoiling in case of hard nospoil filter.
           23 dospoil=0
           24 # Expand meme hashtag and show recommendations.
           25 doexpand=0
           26 
           27 # Personalities.
           28 declare -A personalities
           29 add_personality() {
           30         for personality in "$@";
           31         do
           32                 personalities+=(["${personality}"]="$1")
           33         done
           34 }
           35 for person in preacher uplift trump mao teleromeo modem orphet luther sadh_guru;
           36 do
           37         add_personality "${person}"
           38 done
           39 add_personality grumpy-fart grumpy
           40 add_personality santa sannnta
           41 add_personality satan satannn
           42 add_personality sigmund-freud freud sigmund
           43 
           44 regeximatch() {
           45         printf '%s' "$1" | grep -i -E -q "$2"
           46 }
           47 hashtags() {
           48         cat ${hashtagfile} 2>/dev/null
           49 }
           50 hashtagcount() {
           51         int2bit "$(curl -s gophers://bitreich.org/1/meme/count \
           52                 | grep total \
           53                 | head -n 1 \
           54                 | sed 's,.*total on .*: \([0-9]*\)),\1,')"
           55 }
           56 
           57 isignored=0
           58 for ignorednick in $ignorednicks;
           59 do
           60         [ "$user" = "$ignorednick" ] && isignored=1
           61 done
           62 [ $isignored -eq 1 ] && exit
           63 
           64 case "${IRC_PRIVMSG_TEXT}" in
           65 *\#nospoil*) nospoil=1;;
           66 *\#expand*) doexpand=1;;
           67 *::*::*)
           68         if [ $(pgrep -f stable-diffusion-emoji 2>/dev/null | wc -l) -gt 3 ];
           69         then
           70                 annna-say "${IRC_CMD_USER}, sorry, gophers://bitreich.org/I/memecache/bitreich-burning.png"
           71         else
           72                 {
           73                         query=${IRC_PRIVMSG_TEXT#**::} query=${query%%::*}
           74                         emojiuri="$(stable-diffusion-emoji "${query}")"
           75                         if [ -n "${emojiuri}" ];
           76                         then
           77                                 if [ -n "${IRC_CMD_USER}" ] && [ "${IRC_CMD_USER}" != "annna-cmd" ];
           78                                 then
           79                                         annna-say "${IRC_CMD_USER}, ${emojiuri}"
           80                                 else
           81                                         annna-say "${emojiuri}"
           82                                 fi
           83                         fi
           84                 } &
           85         fi;;
           86 *http*://*|*ytdl://*)
           87         case "${IRC_PRIVMSG_TEXT}" in
           88         *"#spoil"*) dospoil=1;;
           89         esac
           90 
           91         case "${IRC_PRIVMSG_TEXT}" in
           92         *http*://*)
           93                 uri="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" \
           94                         | sed -n '/.*\(https\{0,1\}:\/\/[^ ]\{1,\}\).*/s//\1/p')"
           95                 ;;
           96         *ytdl://*)
           97                 ytid="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" \
           98                         | sed -n '/.*ytdl:\/\/\([^ ]\{1,\}\).*/s//\1/p')"
           99                 uri="$(printf "https://www.youtube.com/watch?v=%s" "${ytid}")"
          100                 ;;
          101         esac
          102 
          103         # Set below and annna will concatenate at the end.
          104         # HTML title.
          105         urititle=""
          106         # Subtitle URI.
          107         sturi=""
          108         # Replacement URI.
          109         nuri=""
          110         # Replacement URI display string.
          111         nuris=""
          112         # html2text content.
          113         curi=""
          114         # Set to 0, if some URI content should be shown.
          115         nocuri=1
          116         # Screenshot.
          117         suri=""
          118 
          119         # titleend=1 will not output any further.
          120         titleend=0
          121         outputstr=""
          122 
          123         if is-invidious-instance "${uri}";
          124         then
          125                 host="$(printf "%s\n" "${uri}" \
          126                         | sed 's,.*://\([^/]*\).*,\1,')"
          127                 if [ -n "${host}" ];
          128                 then
          129                         uri="$(printf "%s\n" "${uri}" \
          130                                 | sed "s,${host},youtube.com,")"
          131                 fi
          132         fi
          133 
          134         tmpf=$(mktemp)
          135         fetch-uri "${uri}" > "${tmpf}"
          136         if [ ! -s "${tmpf}" ];
          137         then
          138                 archiveorguri="$(archiveorg-uri "${uri}")"
          139                 if [ -n "${archiveorguri}" ];
          140                 then
          141                         sarchiveorguri="$(bitreich-uri-shortener "${archiveorguri}")"
          142                         nuris="archive: ${sarchiveorguri}"
          143                         fetch-uri "${archiveorguri}" > "${tmpf}"
          144                 fi
          145         fi
          146         [ -s "${tmpf}" ] && urititle="$(grabtitle < "${tmpf}")"
          147 
          148         case "${urititle}" in
          149         "");;
          150         *Gunther*|*GUNTHER*|*Günther*|*GÜNTHER*)
          151                 annna-say "Oh Günther! ❤  ❤  ❤  ${urititle}"
          152                 uriexpansion=1;;
          153         *\|\ Cloudflare*|"Just a moment...")
          154                 annna-say "Mind your own business! We got clownflared: gophers://bitreich.org/0/ascii/clownflare.vt"
          155                 titleend=1
          156                 uriexpansion=1;;
          157         esac
          158 
          159         case "${uri}" in
          160         "");;
          161         *github.com/*/blob/*)
          162                 urltitle=""
          163                 nuris="$(printf '%s' "${uri}" | sed 's/blob/raw/')"
          164                 nocuri=0;;
          165         *imgur.com/*) nuris="$(youtube-dl -g "${uri}")" || nuris="";;
          166         *xkcd.com/*) nuris="$(xkcd-uri "${uri}")";;
          167         *imdb.com/title/*)
          168                 imdbstr="$(imdb2gopherbay "${uri}")"
          169                 if [ -n "${imdbstr}" ];
          170                 then
          171                         nuris="${imdbstr}"
          172                         urititle=""
          173                 fi;;
          174         # bay.parazy.de is unmaintained
          175         #*themoviedb.org/movie/*)
          176         #        movietitle="$(themoviedb2gopherbay "${uri}" | sed 's, ,+,g')"
          177         #        if [ -n "${movietitle}" ];
          178         #        then
          179         #                nuris="gophers://bay.parazy.de:666/1/q.dcgi?${movietitle}"
          180         #        fi
          181         #        ;;
          182         *lichess.org/????????|*lichess.org/????????/|*lichess.org/????????/black|*lichess.org/????????/white)
          183                 nuris="$(printf "%s\n" "${uri}" \
          184                         | sed 's,https://lichess.org\(/[^ ]*\)$,\1,; s,^/\([^/]*\)/black$,/black/\1,; s,/white,,; s,\(.*\),https://lichess1.org/game/export/gif\1.gif,;')"
          185                 ;;
          186         *npr.org/*)
          187                 post="$(printf '%s\n' "${uri}" | sed -n 's@.*/\([0-9]\{10\}\)/.*$@\1@p')"
          188                 if [ -n "${post}" ];
          189                 then
          190                         nuri="https://text.npr.org/${post}"
          191                         nuris="text only: ${nuri}"
          192                 fi;;
          193         *csdb.dk/release/*)
          194                 sid=$(awk '/<a href="download\.php.*\.sid/ { match($0, /https:\/\/.*\.sid</); print substr($0, RSTART, RLENGTH-1); exit }' "$tmpf")
          195                 [ -n "$sid" ] && nuris="listen: $sid";;
          196         *www.forgottenweapons.com/*)
          197                 ytid=$(sed -n '/<meta name="description"/ s/.*https:\/\/youtu\.be\/\([-A-Za-z0-9_]\{11\}\).*/\1/p' "$tmpf")
          198                 if [ -n "$ytid" ]; then
          199                         nuris="video: ytdl://$ytid ;"
          200                         nuris="$nuris metadata: gophers://codemadness.org/1/idiotbox.cgi?v=$ytid"
          201                 fi;;
          202         *www.reddit.com*)
          203                 nuri="$(printf '%s\n' "${uri}" | sed "s;www.reddit.com;old.reddit.com;")"
          204                 nuris="old.reddit: ${nuri}"
          205                 fetch-uri "${nuri}" > "${tmpf}"
          206                 if [ -n "${uri#*www.reddit.com/r/*}" ];
          207                 then
          208                         subreddit="$(printf '%s\n' "${uri}" | cut -d / -f 5)"
          209                         post="$(printf '%s\n' "${uri}" | cut -d / -f 7)"
          210                         if [ -n "${post}" ];
          211                         then
          212                                 guri="gopher://gopherddit.com/1/cgi-bin/reddit.cgi?view&${post}&${subreddit}&10"
          213                         else
          214                                 guri="gopher://gopherddit.com/1/cgi-bin/reddit.cgi?menu&${subreddit}&10"
          215                         fi
          216                         nuris="${nuri} ; gopherdit: ${guri}"
          217                 fi
          218                 nocuri=0;;
          219         *taz.de*)
          220                 newsid="$(printf '%s\n' "${uri}" | sed 's,.*\(![0-9]*\).*,\1,')"
          221                 if [ -n "${newsid}" ];
          222                 then
          223                         urititle="$(curl-grabtitle "${uri}")"
          224                         nuris="gopher://taz.de/1/${newsid}"
          225                         nocuri=1
          226                 fi;;
          227         *x.com/*/status/*)
          228                 tid="$(printf "%s\n" "${uri}" | sed 's,.*status/\([0-9]*\)$,\1,')"
          229                 if [ -n "${tid}" ];
          230                 then
          231                         nuris="https://twitter-thread.com/pdf/${tid}"
          232                         nocuri=1
          233                 fi;;
          234         *twitter.com*)
          235                 #ninstance="$(nitter-instance | sed 's,\.,\\\.,g')"
          236                 #nuri="$(printf "%s\n" "${uri}" | sed "s;\(mobile\.\)\{0,1\}twitter\.com;${ninstance};")"
          237                 fetch-uri "${uri}" > "${tmpf}"
          238                 urititle="$(curl-grabtitle "${uri}")"
          239                 #suri="$(screenshot-paste "${uri}")"
          240                 #nuris="nitter: ${nuri}"
          241                 nocuri=0;;
          242         *.wikipedia.org/wiki/*)
          243                 if ! regeximatch "$uri" '\.(jpg,bmp,gif,png,tiff,avi,mp4,webm,mkv,pdf,ps,eps)$';
          244                 then
          245                         nuri="$(printf '%s\n' "${uri}" | sed -Ee "s;/wiki/;/api/rest_v1/page/pdf/;" -e "s;(\?|#).*$;;")"
          246                         nuris="$(printf 'pdf: %s\n' "${nuri}")"
          247                         nocuri=1
          248                 fi;;
          249         *youtube.com/*|*youtu.be/*)
          250                 # Youtube is so annoying and repeatedly broken;
          251                 # they hate users, only expand on request.
          252                 if [ $dospoil -eq 1 ];
          253                 then
          254                         if [ -z "${uri##*youtu.be/*}" ] \
          255                                 || [ -z "${uri##*/watch?v=*}" ] \
          256                                 || [ -z "${uri##*/embed/*}" ] \
          257                                 || [ -z "${uri##*/shorts/*}" ];
          258                         then
          259                                 ytid="${uri#http*://*/watch?v=}"
          260                                 ytid="${ytid##*embed/}"
          261                                 ytid="${ytid##*shorts/}"
          262                                 ytid="${ytid##*youtu.be/}"
          263                                 ytid="${ytid%%\?*}"
          264                                 ytid="${ytid%%&*}"
          265                                 nuri="$(get-invidious-instance)/watch?v=${ytid}"
          266                                 ytt="$(printf '%s\n' "${uri}" | sed -n 's/.*[&?]t=\([^&]\{1,\}\).*/\1/p')"
          267                                 [ -n "${ytt}" ] && nuri="${nuri}&t=${ytt}"
          268                         else
          269                                 ytid=""
          270                                 nuri="$(get-invidious-instance)/${uri#https*://*/}"
          271                         fi
          272                         fetch-uri "${nuri}" > "${tmpf}"
          273                         urititle="$(curl-grabtitle "${nuri}")"
          274                         nuris="invidious: ${nuri}"
          275                         if [ -n "${ytid}" ];
          276                         then
          277                                 sturi="$(subtitle-paste "${uri}")"
          278                                 nuris="${nuris} ; metadata: gophers://codemadness.org/1/idiotbox.cgi?v=${ytid}"
          279                         fi
          280                         # If there was no title found, do not display.
          281                         [ -z "${urititle}" ] && titleend=1
          282                         nocuri=1
          283                 else
          284                         titleend=1
          285                 fi;;
          286         *tv.brain.rip/???-???*)
          287                 nuris="$(grep 'property="og:video:secure_url' < "${tmpf}" | sed 's,.*content="\([^"]*\)".*,\1,')"
          288                 urititle="$(grep 'name="description' < "${tmpf}" | sed 's,.*content="\([^"]*\)".*,\1,')"
          289                 nocuri=1;;
          290         *ifdb.org/viewgame*)
          291                 ifdbid="${uri##*ifdb.org/viewgame?id=}"
          292                 nuris="gopher://gopher.0xfa.de/1/pazz0/ifdb2/${ifdbid}.gph"
          293                 nocuri=1;;
          294         *)
          295                 mimetype="$(file -b --mime-type "${tmpf}")"
          296                 case "${mimetype}" in
          297                 text/*|application/javascript) nocuri=0;;
          298                 esac;;
          299         esac
          300 
          301         if [ $titleend -eq 0 ];
          302         then
          303                 if [ $nocuri -eq 0 ];
          304                 then
          305                         [ -z "${curi}" ] && curi="$(html2text < "${tmpf}" | /br/bin/bitreich-paste)"
          306                         outputstr="${outputstr} content: ${curi} ;"
          307                 fi
          308 
          309                 [ -n "${nuris}" ] && outputstr="${outputstr} ${nuris} ;"
          310                 [ -n "${urititle}" ] && outputstr="${outputstr} title: ${urititle} ;"
          311                 [ -n "${suri}" ] && outputstr="${outputstr} screen: ${suri} ;"
          312                 [ -n "${sturi}" ] && outputstr="${outputstr} subtitles: ${sturi} ;"
          313                 annna-say "${outputstr}"
          314                 uriexpansion=1
          315         fi
          316         rm -f "${tmpf}";;
          317 esac
          318 
          319 runlinkbrother=0
          320 for linkbrotherchannel in $linkbrotherchannels;
          321 do
          322         [ "$IRC_CHANNEL" = "$linkbrotherchannel" ] && runlinkbrother=1
          323 done
          324 if [ $runlinkbrother -eq 1 ] && [ $nospoil -eq 0 ];
          325 then
          326         critique="$($ANNNA_MODBASE/linkbrother/linkbrother.sh \
          327                 "$ANNNA_MODBASE/linkbrother/db" \
          328                 "${IRC_CMD_USER}" "${IRC_PRIVMSG_TEXT}")"
          329         [ -n "$critique" ] && annna-say "$critique"
          330 fi
          331 
          332 case "${IRC_PRIVMSG_TEXT}" in
          333 "${IRC_USER}"?)
          334         exclamation="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | sed "s,${IRC_USER}\(.\),\1,g")"
          335         exclamationsintime=$(exclamatio "${IRC_CMD_USER}")
          336         finalexclamation="${exclamation}"
          337         while [ $exclamationsintime -gt 1 ];
          338         do
          339                 finalexclamation="${finalexclamation}${exclamation}"
          340                 exclamationsintime=$(($exclamationsintime - 1))
          341         done
          342         annna-say "${IRC_CMD_USER}${finalexclamation}";;
          343 "${IRC_USER}, how old are you?")
          344         age="$(ddiff ${annnabirthday} today -f "%y")"
          345         annna-say "${IRC_CMD_USER}, I am ${age} years old.";;
          346 "${IRC_USER}, when is your birthday?") annna-say "${IRC_CMD_USER}, I am born on ${annnabirthday}.";;
          347 "${IRC_USER}, asl"*) annna-say "${IRC_CMD_USER}, age: born on 1989-05-18; sex: IRC bot; location: bitreich.org; u?";;
          348 "${IRC_USER}, woop")
          349         # Using the same database for funny hacks.
          350         exclamation="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | sed "s;${IRC_USER}, \(.\);\1;g")"
          351         exclamationsintime=$(exclamatio "${IRC_CMD_USER}")
          352         finalexclamation="${exclamation}"
          353         while [ $exclamationsintime -gt 1 ];
          354         do
          355                 finalexclamation="${finalexclamation} ${exclamation}"
          356                 exclamationsintime=$(($exclamationsintime - 1))
          357         done
          358         annna-say "${IRC_CMD_USER}, ${finalexclamation}";;
          359 "${IRC_USER}, hype")
          360         # Using the same database for funny hacks.
          361         exclamation="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | sed "s;${IRC_USER}, \(.\);\1;g")"
          362         exclamationsintime=$(exclamatio "${IRC_CMD_USER}")
          363         finalexclamation="${exclamation}"
          364         while [ $exclamationsintime -gt 1 ];
          365         do
          366                 finalexclamation="${finalexclamation} ${exclamation}"
          367                 exclamationsintime=$(($exclamationsintime - 1))
          368         done
          369         annna-say "${IRC_CMD_USER}, ${finalexclamation}";;
          370 *">:3"*) annna-say "OMG IT'S A LION GET IN THE CAR!";;
          371 *"<3"*)
          372         love "${IRC_CMD_USER}++"
          373         annna-say "*o.o*";;
          374 *"m(") annna-say "(-‸ლ)";;
          375 *"*shrug*"*) annna-say "¯\\_(ツ)_/¯";;
          376 *"*glare*"*) annna-say "ಠ_ಠ";;
          377 *"*finger*"*) annna-say "╭∩╮(ಠ_ಠ)╭∩╮";;
          378 *"*yolo*"*) annna-say "Yᵒᵘ Oᶰˡʸ Lᶤᵛᵉ Oᶰᶜᵉ";;
          379 *":'(") annna-say "(╯︵╰,)";;
          380 "Thanks ${IRC_USER}"*) annna-say "${IRC_CMD_USER}, you are welcome.";;
          381 *" ope sorry"*|"ope sorry"*) annna-say "${IRC_CMD_USER}, 😃pe sorry.";;
          382 "${IRC_USER}, snake"*) annna-say "${IRC_CMD_USER}, ssSSsSssSssSsssssSSsSSSSsSssSSSSsssSSSSsssSSsssSssssSssssSSssSSsSssssSSsSSssSsssSssSSSS";;
          383 "${IRC_USER}, snoke"*) annna-say "${IRC_CMD_USER}, snoke again?";;
          384 "${IRC_USER}, amirite?") annna-say "${IRC_CMD_USER}, Yep, you're the most correct of them all.";;
          385 "${IRC_USER}, ping"*) annna-say "${IRC_CMD_USER}, pong.";;
          386 "${IRC_USER}, how lame is my nick?") annna-say "$(lameness "${IRC_CMD_USER}")";;
          387 "${IRC_USER}, ding"*) annna-say "${IRC_CMD_USER}, dong.";;
          388 "${IRC_USER}, irly"*) annna-say "${IRC_CMD_USER}, I love you too.";;
          389 "${IRC_USER}, bleep bloop"*) annna-say "${IRC_CMD_USER}, bloop bleep." ;;
          390 "${IRC_USER}, snare"*) annna-say "${IRC_CMD_USER}, not snare again!";;
          391 "${IRC_USER}, I am mad"*) annna-say "${IRC_CMD_USER}, we have a MAD SCIENTIST ONBOARD :>";;
          392 "${IRC_USER}, I am holy"*) annna-say "${IRC_CMD_USER}, Holy shit this guy is totally NUTS!!!";;
          393 "${IRC_USER}, please compliment me"*) annna-say "${IRC_CMD_USER}, you rock!";;
          394 "${IRC_USER}, what the karma?") annna-say "${IRC_CMD_USER}, gophers://bitreich.org/1/irc/karma";;
          395 "${IRC_USER}, who is lovely?") annna-say "${IRC_CMD_USER}, gophers://bitreich.org/1/irc/love";;
          396 "${IRC_USER}, what the brcon score?") annna-say "${IRC_CMD_USER}, gophers://bitreich.org/1/con/$(date +%Y)/score";;
          397 "${IRC_USER}, what the shame?") annna-say "${IRC_CMD_USER}, gophers://bitreich.org/1/irc/shame";;
          398 "${IRC_USER}, please generate a password for me.") annna-say "${IRC_CMD_USER}, as you wish: $(pwgen -B1ny 20 10 | paste -sd ' ')";;
          399 *"don't care"*) annna-say "${IRC_CMD_USER}, $(shuf -n 1 ${idontcaredb})";;
          400 "${IRC_USER}, how can I phlog on bitreich?") annna-say "${IRC_CMD_USER}, please read: gophers://bitreich.org/0/usr/20h/phlog/2017-08-26T20-04-02-482296.md and gophers://bitreich.org/0/usr/20h/phlog/2017-08-26T20-27-40-281825.md";;
          401 "${IRC_USER}, what's my type?")
          402         {
          403                 cd /br/gopher
          404                 usertype="$(find memecache/type-?.png -type f \
          405                         | shuf -n 1 \
          406                         | xargs -n 1 printf "gophers://bitreich.org/9%s\n")"
          407                 annna-say "${IRC_CMD_USER}, your type is ${usertype}"
          408         };;
          409 "${IRC_USER}, please show me a video about "*)
          410         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 37-)"
          411         case "$word" in
          412         *\?) word="$(printf "%s\n" "${word}" | cut -c -"$((${#word} - 1))")";;
          413         esac
          414         videoresult="$(idiotbox-roulette "${word}")"
          415         if [ -n "${videoresult}" ];
          416         then
          417                 annna-say "${IRC_CMD_USER}, ${videoresult}"
          418         else
          419                 annna-say "${IRC_CMD_USER}, sorry, nothing founds."
          420         fi;;
          421 "${IRC_USER}, what is my fortune?")
          422         fortunecookie="$(fortune-cookie)"
          423         [ -n "${fortunecookie}" ] && annna-say "${IRC_CMD_USER}, ${fortunecookie}";;
          424 "${IRC_USER}, what is "*)
          425         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 16-)"
          426         case "$word" in
          427         *\?) word="$(printf "%s\n" "${word}" | cut -c -"$((${#word} - 1))")";;
          428         esac
          429 
          430         dictserver="dict.org"
          431         case "${word}" in
          432         dict.org*)
          433                 dictserver="dict.org"
          434                 word="$(printf "%s\n" "${word}" | cut -c 9-)"
          435                 ;;
          436         # parazy.de is unmaintained
          437         #parazy.de*)
          438         #        dictserver="parazy.de"
          439         #        word="$(printf "%s\n" "${word}" | cut -c 10-)"
          440         #        ;;
          441         esac
          442 
          443         dresult="$(dictcurl "${dictserver}" "" "${word}")"
          444         if [ -z "${dresult}" ];
          445         then
          446                 puri="No match found."
          447         else
          448                 puri="$(printf "%s\n" "${dresult}" | /br/bin/bitreich-paste)"
          449         fi
          450         annna-say "${puri}";;
          451 "${IRC_USER}, cowsay "*)
          452         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 15-)"
          453         tmpf=$(mktemp)
          454         if cowsayasaservice ${word} > ${tmpf}; then
          455                 curi="$(/br/bin/bitreich-paste < ${tmpf})"
          456                 annna-say "${IRC_CMD_USER}: the cow said... ${curi}"
          457         fi
          458         rm ${tmpf} 2>/dev/null;;
          459 "${IRC_USER}, please give me the unix power"*)
          460         upcuri="$(unix-power)"
          461         [ -n "${upcuri}" ] && annna-say "${IRC_CMD_USER}, ${upcuri}";;
          462 "${IRC_USER}, please stop the last emoji prompt"*)
          463         lastemojipromptpid="$(pgrep -f stable-diffusion-emoji | sort -n | tail -n 1)"
          464         if [ -n "${lastemojipromptpid}" ];
          465         then
          466                 pstree -A -p "${lastemojipromptpid}" | grep -Eow "[0-9]+" | xargs kill
          467                 annna-say "${IRC_CMD_USER}, I HUPed ${lastemojipromptpid} and all its children for you."
          468         else
          469                 annna-say "${IRC_CMD_USER}, sorry, no instances found."
          470         fi;;
          471 "${IRC_USER}, play despacito "*) annna-say "${IRC_CMD_USER}, gophers://bitreich.org/9/memecache/despacito.mkv";;
          472 "nice to meet you ${IRC_USER}"*) annna-say "${IRC_CMD_USER}, the pleasure is on my side. :-)";;
          473 "${IRC_USER}, please give me a Chuck Norris fact"*) annna-say "${IRC_CMD_USER}, $(chucknorris)";;
          474 "${IRC_USER}, magic"*)
          475         magictrick="$(magic)"
          476         [ -n "${magictrick}" ] && annna-say "${IRC_CMD_USER}, ${magictrick}";;
          477 "${IRC_USER}, please show me ip art"*)
          478         annna-say "${IRC_CMD_USER}, please see #bitreich-tv for the magic."
          479         {
          480                 cd $HOME/bin/modules/ip-art;
          481                 # Lock, so only one annna process manipulates eth0.
          482                 flock $HOME/bin/modules/ip-art -c "./display-file.sh ip-art.ipart"
          483         } & ;;
          484 "${IRC_USER}, I feel button"*)
          485         buri="$(button-gen)"
          486         if [ -n "${buri}" ];
          487         then
          488                 annna-say "${IRC_CMD_USER}, like this? ${buri}"
          489         else
          490                 annna-say "${IRC_CMD_USER}, sorry, no feelings for you today."
          491         fi;;
          492 "${IRC_USER}, I feel stupid"*)
          493         nuri=$(darwin)
          494         tmpf=$(mktemp)
          495         fetch-uri "${nuri}" > "${tmpf}"
          496         curi="$(9 htmlfmt < "${tmpf}" | /br/bin/bitreich-paste)"
          497         annna-say "${IRC_CMD_USER}, do not feel stupid, others are more stupid: ${curi}"
          498         rm ${tmpf} 2>/dev/null;;
          499 "${IRC_USER}, I feel down"*)
          500         postmortem="$(post-mortem | /br/bin/bitreich-paste)"
          501         annna-say "${IRC_CMD_USER}, do not feel bad, others had worse days: ${postmortem}";;
          502 "${IRC_USER}, I feel perl"*)
          503         perlfeelings="$(perl-feelings)"
          504         [ -n "${perl-feelings}" ] && annna-say "${IRC_CMD_USER}, I feel ${perlfeelings}";;
          505 "${IRC_USER}, will you be my girlfriend?") annna-say "${IRC_CMD_USER}, $(girlfriend)";;
          506 "${IRC_USER}, who fights crime?"|"${IRC_USER}, who is fighting crime?")
          507         partner=$(echo $brmembers | awk '{for (i = 1; i < NF; i++) print $i}' | grep -v "^{$user}" | shuf -n 1)
          508         crimefighter="$(theyfightcrime ${IRC_CMD_USER} ${partner})"
          509         annna-say "${crimefighter}";;
          510 "${IRC_USER}, please give me a commit message"*) annna-say "${IRC_CMD_USER}, $(whatthecommit)";;
          511 "${IRC_USER}, please paint the irc channel.")
          512         emojiuri="$(emoji-channel-history "${ANNNA_IRCBASE}/${IRC_SERVER}/${IRC_CHANNEL}")"
          513         [ -n "${emojiuri}" ] && annna-say "${emojiuri}";;
          514 "${IRC_USER}, birp"*) annna-say "${IRC_CMD_USER}, I heard a $(bird-name) bird.";;
          515 "${IRC_USER}, please oneline me"*)
          516         randomoneliner="$(oneliner)"
          517         if [ -z "${randomoneliner}" ];
          518         then
          519                 annna-say "${IRC_CMD_USER}, the service failed. Please redial to your BOL account."
          520         else
          521                 annna-say "${IRC_CMD_USER}, ${randomoneliner}"
          522         fi;;
          523 *"what's app?")
          524         maemoapp="$(whatsapp)"
          525         [ -n "${maemoapp}" ] && annna-say "Have you tried? ${maemoapp}";;
          526 "${IRC_USER}, man "*|"${IRC_USER}, man "*)
          527         exp="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 12- | sed 's,\t,    ,g')"
          528         dresult="$(COLUMNS=80 man "${exp}" 2>/dev/null)"
          529         if [ "$dresult" ];
          530         then
          531                 puri="$(printf "%s" "${dresult}" | /br/bin/bitreich-paste)"
          532         else
          533                 puri="No matches found."
          534         fi
          535         annna-say "${puri}";;
          536 "${IRC_USER}, please pray for me"*) annna-say "${IRC_CMD_USER}, here, for you: gophers://bitreich.org/9/memecache/llaminim.mkv";;
          537 "${IRC_USER}, nigger."|*nigger*|*NIGGER*) annna-say "${IRC_CMD_USER}, don't use the $(nword)!";;
          538 "${IRC_USER}, why was I breached?")
          539         breachtext="$(why-was-i-breached)"
          540         [ -n "${breachtext}" ] && annna-say "${IRC_CMD_USER}, ${breachtext}";;
          541 "${IRC_USER}, please be responsible about "*)
          542         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 36- | sed 's,\t,    ,g')"
          543         suri="$(responsibility "${word}"  | bitreich-paste)"
          544         annna-say "${suri}";;
          545 "${IRC_USER}, please say "*)
          546         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 19- | sed 's,\t,    ,g')"
          547         suri="$(printf "%s\n" "${word}" | bitreich-speak)"
          548         annna-say "${suri}";;
          549 "${IRC_USER}, please zombie say "*)
          550         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 26- | sed 's,\t,    ,g')"
          551         suri="$(printf "%s\n" "${word}" | zombie -e | bitreich-speak)"
          552         annna-say "${suri}";;
          553 "${IRC_USER}, please unzombie "*)
          554         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 24- | sed 's,\t,    ,g')"
          555         suri="$(printf "%s\n" "${word}" | zombie -d)"
          556         annna-say "${suri}";;
          557 "${IRC_USER}, please zombie "*)
          558         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 22- | sed 's,\t,    ,g')"
          559         suri="$(printf "%s\n" "${word}" | zombie -e)"
          560         annna-say "${suri}";;
          561 "${IRC_USER}, please ghost say "*)
          562         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 25- | sed 's,\t,    ,g')"
          563         suri="$(printf "%s\n" "${word}" | ghost -e | bitreich-speak)"
          564         annna-say "${suri}";;
          565 "${IRC_USER}, please unghost "*)
          566         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 23- | sed 's,\t,    ,g')"
          567         suri="$(printf "%s\n" "${word}" | ghost -d)"
          568         annna-say "${suri}";;
          569 "${IRC_USER}, please ghost "*)
          570         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 21- | sed 's,\t,    ,g')"
          571         suri="$(printf "%s\n" "${word}" | ghost -e)"
          572         annna-say "${suri}";;
          573 "${IRC_USER}, please pohlish "*)
          574         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 23- | sed 's,\t,    ,g')"
          575         suri="$(pohlcode.awk "${word}" | head -n 1)"
          576         annna-say "${suri}";;
          577 "${IRC_USER}, please cunei "*)
          578         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 21- | sed 's,\t,    ,g')"
          579         suri="$(int2cunei "${word}" | head -n 1)"
          580         annna-say "${suri}";;
          581 "${IRC_USER}, what is up with gopher man?");; #TODO
          582 "${IRC_USER}, what can I cook with "*)
          583         ingredients="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 29- | sed 's,\t,    ,g')"
          584         case "$ingredients" in
          585         *\?) ingredients="$(printf "%s\n" "${ingredients}" | cut -c -"$(($(expr length "${ingredients}") - 1))")";;
          586         esac
          587         results="$(fridge-recipe-search "${ingredients}")"
          588         if [ -n "${results}" ];
          589         then
          590                 puri="$(printf "%s\n" "${results}" | bitreich-paste | sed 's,0p,1p,')"
          591                 annna-say "${IRC_CMD_USER}, here are some recipes: ${puri}"
          592         else
          593                 gptchefrecipe="$(gpt-chef "${ingredients}")"
          594                 if [ -n "${gptchefrecipe}" ];
          595                 then
          596                         annna-say "${IRC_CMD_USER}, there was no ready-made recipe, so maybe this is an idea: ${gptchefrecipe}"
          597                         if [ $(pgrep -f stable-diffusion-emoji 2>/dev/null | wc -l) -lt 3 ];
          598                         then
          599                                 {
          600                                         emojiuri="$(stable-diffusion-emoji "${gptchefrecipe}")"
          601                                         if [ -n "${emojiuri}" ];
          602                                         then
          603                                                 annna-say "${emojiuri}"
          604                                         fi
          605                                 } &
          606                         fi
          607                 else
          608                         annna-say "${IRC_CMD_USER}, I could not find any recipes for you."
          609                 fi
          610         fi;;
          611 "${IRC_USER}, gpt "*)
          612         prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 12- | sed 's,\t,    ,g')"
          613         {
          614                 annna-say "$(gpt "${prompt}. Please answer short and precise.")"
          615         } & ;;
          616 "${IRC_USER}, wolfram is "*)
          617         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 19- | sed 's,\t,    ,g')"
          618         case "$word" in
          619         *\?) word="$(printf "%s\n" "${word}" | cut -c -"$(($(expr length "${word}") - 1))")";;
          620         esac
          621         puri=""
          622         dresult="$(printf "/wolfram\t%s\r\n" "${word}" \
          623                 | nc magical.fish 70 \
          624                 | awk '/iAnswer:/,/iAsk/' \
          625                 | grep -v '^i ' \
          626                 | head -n -1 \
          627                 | tail -n +2 \
          628                 | sed 's,i\(.*\)fake\texample.com.*,\1,;s,[ \t]*$,,')"
          629         if [ -n "$dresult" ];
          630         then
          631                 case "${dresult}" in
          632                 b*)     dresult="$(printf "%s\n" "${dresult}" \
          633                                 | tr '\n' ' ' \
          634                                 | sed "s,^b',,;s,' $,," \
          635                                 | sed 's,^b",,;s," $,,' \
          636                                 | sed 's,\\n,\n,g;s,\\t,\t,g')"
          637                         ;;
          638                 *)      dresult="$(printf "%s\n" "${dresult}" \
          639                                 | sed 's,\([a-zA-Z]\)$,\1 ,' \
          640                                 | tr -d '\n')"
          641                         ;;
          642                 esac
          643                 wcl="$(printf "%s" "${dresult}" | wc -l)"
          644                 if [ $wcl -gt 1 ];
          645                 then
          646                         puri="$(printf "%s" "${dresult}" | /br/bin/bitreich-paste)"
          647                 else
          648                         puri="${dresult}"
          649                 fi
          650         else
          651                 puri="No matches found."
          652         fi
          653         annna-say -- "${puri}";;
          654 # Emulate https://threats.kaspersky.com/en/threat/IRC-Worm.DOS.Septic/
          655 "${IRC_USER}, pray"*) annna-say "${IRC_CMD_USER}, I Obey my master! long live satan";;
          656 "${IRC_USER}, sacrifice"*) annna-say "${IRC_CMD_USER}, Your word is my command, Power to satan!";;
          657 "${IRC_USER}, please scare me"*) annna-say "$(halloween)" & ;;
          658 "${IRC_USER}, how drunk is "*)
          659         {
          660                 drunknick="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" \
          661                         | sed 's,.*how drunk is \(.*\),\1,' \
          662                         | tr -d '?')"
          663                 drunkness="$(drunk-meter "${ANNNA_IRCBASE}/${IRC_SERVER}/${IRC_CHANNEL}/out" "${drunknick}")"
          664                 if [ -n "${drunkness}" ];
          665                 then
          666                         annna-say "${IRC_CMD_USER}, ${drunknick} is ${drunkness} drunk."
          667                 fi
          668         } & ;;
          669 "${IRC_USER}, how do I "*)
          670         {
          671                 gptprompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" \
          672                         | sed 's,.*how do I \(.*\),\1,' \
          673                         | tr -d '?')"
          674                 gpturi="$(gpt "how do I ${gptprompt}" | bitreich-paste)"
          675                 if [ -n "${gpturi}" ];
          676                 then
          677                         annna-say "${IRC_CMD_USER}, try this: ${gpturi}"
          678                 fi
          679         } & ;;
          680 "${IRC_USER}, weather at "*|"${IRC_USER}, weather in "*)
          681         {
          682                 weatherplace="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" \
          683                         | sed 's,.*weather .. \(.*\),\1,' \
          684                         | tr -d '?')"
          685                 if weathertext="$(weather "${weatherplace}")"
          686                 then
          687                         annna-say "${IRC_CMD_USER}, the weather at ${weatherplace} is ${weathertext}"
          688                 else
          689                         annna-say "${IRC_CMD_USER}, there is no weather at ${weatherplace}."
          690                 fi
          691         } & ;;
          692 "${IRC_USER}, funny weather at "*|"${IRC_USER}, funny weather in "*)
          693         {
          694                 weatherplace="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" \
          695                         | sed 's,.*funny weather .. \(.*\),\1,' \
          696                         | tr -d '?')"
          697                 personality="funny-weather-reporter"
          698                 preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.txt)"
          699                 if weathertext="$(weather "${weatherplace}")"
          700                 then
          701                         prompt="$(printf "%s\n" "${weathertext}" | cut -d' ' -f 2- | sed 's,\t,    ,g')"
          702                         {
          703                                 annna-say "${IRC_CMD_USER}, $(gpt "System: ${preprompt}\n User: ${prompt}\n Bot:")"
          704                         } &
          705                 else
          706                         weathertext="there is no weather at ${weatherplace}"
          707                         prompt="${weathertext}"
          708                         {
          709                                 annna-say "${IRC_CMD_USER}, $(gpt "System: ${preprompt}\n User: ${prompt}\n Bot:")"
          710                         } &
          711                 fi
          712         } & ;;
          713 "${IRC_USER}, color weather at "*|"${IRC_USER}, color weather in "*)
          714         {
          715                 weatherplace="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" \
          716                         | sed 's,.*color weather .. \(.*\),\1,' \
          717                         | tr -d '?')"
          718                 personality="color-weather-reporter"
          719                 preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.txt)"
          720                 if weathertext="$(weather "${weatherplace}")"
          721                 then
          722                         prompt="$(printf "%s\n" "${weathertext}" | cut -d' ' -f 2- | sed 's,\t,    ,g')"
          723                         {
          724                                 annna-say "${IRC_CMD_USER}, $(gpt "System:${preprompt}\nUser:${prompt}\nBot:")"
          725                         } &
          726                 else
          727                         weathertext="there is no weather at ${weatherplace}"
          728                         prompt="${weathertext}"
          729                         {
          730                                 annna-say "${IRC_CMD_USER}, $(gpt "System:${preprompt}\nUser:${prompt}\nBot:")"
          731                         } &
          732                 fi
          733         } & ;;
          734 "${IRC_USER}, METAR for "*|"${IRC_USER}, metar for "*|"${IRC_USER}, metar for "*|"${IRC_USER}, METAR for "*)
          735         resp=$(metar "$(printf '%.4s\n' "${IRC_PRIVMSG_TEXT##* }")")
          736         annna-say "${IRC_CMD_USER}, ${resp}";;
          737 "${IRC_USER}, how discriminating is "*)
          738         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 30- | sed 's,\t,    ,g')"
          739         case "$word" in
          740         *\?) word="$(printf "%s\n" "${word}" | cut -c -"$(($(expr length "${word}") - 1))")";;
          741         esac
          742         newword="$(discrimination-filter "${word}")"
          743         if [ "${newword}" = "${word}" ];
          744         then
          745                 annna-say "${IRC_CMD_USER}, it is ok."
          746         else
          747                 annna-say "${IRC_CMD_USER}, it should be: ${newword}"
          748         fi;;
          749 "${IRC_USER}, are "*)
          750         case "${IRC_PRIVMSG_TEXT}" in
          751         *" in love?")
          752                 words="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | sed 's,.*are \(.*\) and \(.*\) in love?,\1 \2,')"
          753                 lovedistance="$(printf "%s * 100\n" "$(fstrcmp ${words})" | bc | cut -d'.' -f 1)"
          754                 if [ $lovedistance -gt 15 ];
          755                 then
          756                         annna-say 'Yes!!! Pure <3 <3'
          757                 else
          758                         annna-say "No."
          759                 fi;;
          760         esac;;
          761 "${IRC_USER}, is "*)
          762         aitext="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 7- | sed 's,\t,    ,g')"
          763         airesult="$(printf "%s\n" "${aitext}" | josuah-ai)"
          764         [ -n "${airesult}" ] && annna-say "${IRC_CMD_USER},${airesult}";;
          765 [Oo]"k, ${IRC_USER}"*) annna-say "${IRC_CMD_USER}, I am not a consumer device.";;
          766 "${IRC_USER}, please shoot "*|"${IRC_USER}, plese shoot "*)
          767         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 21-)"
          768         annna-say "${word}, #pewpew gophers://bitreich.org/9/memecache/pewpew.mp4";;
          769 "${IRC_USER}, please quinq.") annna-say "┻━┻ ︵╰(°□°)╯︵ ┻━┻";;
          770 "${IRC_USER}, please flip "*)
          771         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 20-)"
          772         updownword="$(updown "${word}")"
          773         annna-say "(╯°□°)╯ ${word} ︵ ${updownword}";;
          774 "${IRC_USER}, please crystal math "*)
          775         math="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 28-)"
          776         crystaluri="$(crystal-math "${math}")"
          777         annna-say "${IRC_CMD_USER}, please see ${crystaluri}";;
          778 "${IRC_USER}, please australize "*)
          779         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 26-)"
          780         updownword="$(updown "${word}")"
          781         annna-say "${word} -> ${updownword}";;
          782 "${IRC_USER}, wtf "*)
          783         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 11-)"
          784         wtfword="$(wtf "${word}" 2>/dev/null)"
          785         [ -n "${wtfword}" ] && annna-say "${IRC_CMD_USER}, ${wtfword}";;
          786 "${IRC_USER}, please give me a good band name"*) annna-say "$(bandname-gen | shuf | head -n 1)";;
          787 "${IRC_USER}, I feel conspicuous"*) annna-say "Maybe declare this: $(manifesto-gen | bitreich-paste)";;
          788 "${IRC_USER}, I am horny"*) annna-say "Here is some intellectual porn for you: $(bithub-gen)";;
          789 "${IRC_USER}, please turn on "*)
          790         word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 22-)"
          791         annna-say "☞ ⏻ ${word}";;
          792 "${IRC_USER}, please turn me on"*) annna-say "☞ ⏻ ${IRC_CMD_USER}";;
          793 "${IRC_USER}, I'm game bored.")
          794         gamelink="$(abandonware-random-game)"
          795         if [ -z "${gamelink}" ];
          796         then
          797                 annna-say "${IRC_CMD_USER}, sorry I have found nothing for you."
          798         else
          799                 annna-say "${IRC_CMD_USER}, have you tried ${gamelink} ?"
          800         fi;;
          801 "${IRC_USER}, I need a waifu"*)
          802         waifuuris="$(waifu-gen)"
          803         [ -n "${waifuuris}" ] && annna-say "${IRC_CMD_USER}, ${waifuuris}";;
          804 "${IRC_USER}, I need an anime"*)
          805         animeuri="$(anime-gen)"
          806         [ -n "${animeuri}" ] && annna-say "${IRC_CMD_USER}, ${animeuri}";;
          807 "${IRC_USER}, I'm gopher bored"*)
          808         randomlink="$(/br/bin/bitreich-lawn-random-link)"
          809         linktype="$(printf "%s\n" "${randomlink}" | cut -d '|' -f1 | cut -c2-)"
          810         linktext="$(printf "%s\n" "${randomlink}" | cut -d '|' -f2)"
          811         linksel="$(printf "%s\n" "${randomlink}" | cut -d '|' -f3)"
          812         linkserver="$(printf "%s\n" "${randomlink}" | cut -d '|' -f4)"
          813         linkport="$(printf "%s\n" "${randomlink}" | cut -d '|' -f5 | cut -d']' -f1)"
          814         outtext="$(printf "%s - gopher://%s" "$linktext" "$linkserver")"
          815         [ "$linkport" != "70" ] && [ "$linkport" != "port" ] && outtext="$(printf "%s:%s" "$outtext" "$linkport")"
          816         [ -n "$linksel" ] && outtext="$(printf "%s/%s%s" "$outtext" "$linktype" "$linksel")"
          817         annna-say "$outtext";;
          818 "${IRC_USER}, wb"*) annna-say "${IRC_CMD_USER}, ty! I am so happy to be here. :)";;
          819 "${IRC_USER}, welcome back"*) annna-say "${IRC_CMD_USER}, thank you! I am so happy to be here. :)";;
          820 "${IRC_USER}, I love you"*) annna-say $'\001ACTION blushes\001';;
          821 "${IRC_USER}, bon"*) annna-say "${IRC_CMD_USER}, $(bonjour) !";;
          822 "${IRC_USER}, salut"*) annna-say "${IRC_CMD_USER}, Salutations camarade !";;
          823 "${IRC_USER}, what's up?") annna-say "$(ecl -shell /home/solene/gopher/bin/generator.lisp)";;
          824 "${IRC_USER}, what's down?") annna-say "${IRC_CMD_USER}, we all love you.";;
          825 $'\001'"ACTION cancels "*)
          826         mobtarget="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | sed 's,.*ACTION cancels \(.*\)\x01,\1,')"
          827         cancel-target "${mobtarget}"
          828         annna-say "${IRC_CMD_USER}, I cancelled ${mobtarget} for you. ( gophers://bitreich.org/I/memecache/cancel-meteor.jpg )";;
          829 $'\001'"ACTION pokes ${IRC_USER}"$'\001') annna-say "$(echo -e '\001')ACTION pokes ${IRC_CMD_USER}$(echo -e '\001')";;
          830 "${IRC_USER}, please show me the mob"*|"${IRC_USER}, what are the mob"*) annna-say "${IRC_CMD_USER}, $(get-cancel-list)";;
          831 "${IRC_USER}, I feel sick"*)
          832         newsstr="$(cd /br/gopher/hypochondria && ./hypochondria -s random)"
          833         annna-say "You could have ${newsstr}! Be careful!";;
          834 *"oh hai"*|*"ohai"*|*"ohhai"*) annna-say "${IRC_CMD_USER}, hai! How is your sex life?";;
          835 "o/"|"o/ "*|"\o"|"\o "*|"o7"|"o7 "*) annna-say "${IRC_CMD_USER}, ${IRC_PRIVMSG_TEXT}";;
          836 "\m/"|"\m/ "*) annna-say "${IRC_CMD_USER}, ᕦ(ò_óˇ)ᕤ";;
          837 *"*waves*"*|*"*wave*"*) annna-say "${IRC_CMD_USER}, *wave*";;
          838 "twtcs"*|"TWTCS"*) annna-say "${IRC_CMD_USER}, maybe: https://constitution.congress.gov/constitution/";;
          839 "twss"*|"TWSS"*) annna-say "${IRC_CMD_USER}, no, I didn't.";;
          840 *"cows are nice"*) annna-say "${IRC_CMD_USER}, 'Cows are nice, unless you are a blade of grass.' -- Mr. Qi Ng (2023)";;
          841 "${IRC_USER}, please make me a coffee"*) annna-say "${IRC_CMD_USER}, ☕";;
          842 "${IRC_USER}, please tech hype me"*) annna-say "$(tech-hype)";;
          843 "${IRC_USER}, please french hype me"*) annna-say "$(french-hype)";;
          844 "${IRC_USER}, please coffee read "*)
          845         readtarget="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 27-)"
          846         horostr="$($HOME/scm/bullshit/horoscope)"
          847         annna-say "${readtarget}, ${horostr}";;
          848 "${IRC_USER}, what's my horoscope?") annna-say "${IRC_CMD_USER}, $($HOME/scm/bullshit/horoscope)";;
          849 "${IRC_USER}, what should I cook"*)
          850         recipestr="$(based.recipe)"
          851         if [ -n "${recipestr}" ];
          852         then
          853                 annna-say "${IRC_CMD_USER}, ${recipestr}"
          854         else
          855                 gptchefrecipe="$(gpt-chef "something random")"
          856                 if [ -n "${gptchefrecipe}" ];
          857                 then
          858                         annna-say "${IRC_CMD_USER}, ${gptchefrecipe}"
          859                         if [ $(pgrep -f stable-diffusion-emoji 2>/dev/null | wc -l) -lt 3 ];
          860                         then
          861                                 {
          862                                         emojiuri="$(stable-diffusion-emoji "${gptchefrecipe}")"
          863                                         if [ -n "${emojiuri}" ];
          864                                         then
          865                                                 annna-say "${emojiuri}"
          866                                         fi
          867                                 } &
          868                         fi
          869                 else
          870                         annna-say "${IRC_CMD_USER}, I have no recommendation for you today."
          871                 fi
          872         fi;;
          873 # parazyd.org is unmaintained
          874 #"${IRC_USER}, what's my future?")
          875 #        puri="$(sacc gopher://parazyd.org/0/tarot.cgi | /br/bin/bitreich-paste)"
          876 #        annna-say "${IRC_CMD_USER}, your future is here: ${puri}"
          877 #        ;;
          878 "${IRC_USER}, haha"*)
          879         { 
          880                 wuri="$(github-haha)"
          881                 [ -n "${wuri}" ] && annna-say "${IRC_CMD_USER}, haha ${wuri}"
          882         } & ;;
          883 "${IRC_USER}, meow"*)
          884         # https://catgps.wvd.io support
          885         nmeows=$(($RANDOM % 14))
          886         meows="Meow"
          887         for i in $(seq $nmeows);
          888         do
          889                 meows="$meows meow"
          890         done
          891         if [ $nmeows -lt 4 ];
          892         then
          893                 meows="$meows!"
          894         else
          895                 meows="$meows."
          896         fi
          897         annna-say "${IRC_CMD_USER}, ${meows}";;
          898 "${IRC_USER}, how many memes do you know?") annna-say "I know $(hashtagcount) memes: gophers://bitreich.org/1/meme/count";;
          899 "${IRC_USER}, please show me your memes"*)
          900         puri="$(printf "%s" "$(hashtags)" | /br/bin/bitreich-paste)"
          901         annna-say "Here are my memes: ${puri}";;
          902 "${IRC_USER}, please show me the victims"*)
          903         puri="$(printf "%s" "$(hashtags)" | grep victim | /br/bin/bitreich-paste)"
          904         annna-say "Here are the victims: ${puri}";;
          905 "${IRC_USER}, please distro-hop with me"*)
          906         ndistro="$(curl -s 'https://distrowatch.com/dwres.php?resource=popularity' \
          907                 | grep phr2 \
          908                 | sed 's,.*href="\(.*\)".*,\1,' \
          909                 | sort | uniq | shuf -n 1)"
          910         annna-say "How about https://distrowatch.com/${ndistro} ?";;
          911 "${IRC_USER}, please show me your Macron"*) annna-say "gophers://bitreich.org/0/ascii/macron.vt";;
          912 "${IRC_USER}, release the Kraken"*) annna-say "Here it is! gophers://bitreich.org/0/memecache/kraken.vt";;
          913 "${IRC_USER}, where is your source?") annna-say "Here is my precious source: git://bitreich.org/annna ";;
          914 "${IRC_USER}, release the Quacken!") annna-say "Quack Quack! gophers://bitreich.org/9/memecache/release-the-quacken.mkv";;
          915 "${IRC_USER}, be cool"*)
          916         case "$(($RANDOM % 5))" in
          917         0) annna-say "(⌐■_■)";;
          918         1) annna-say "(▰˘◡˘▰)";;
          919         2) annna-say "(▀ Ĺ▀ )̄";;
          920         3) annna-say "(▀Ĺ▀ )";;
          921         *) annna-say "I can't be cool! gophers://bitreich.org/9/memecache/i-cant-be-cool.mp3";;
          922         esac;;
          923 "${IRC_USER}, please cheer"*)
          924         case "$(($RANDOM % 2))" in
          925         0) annna-say '~\o/~';;
          926         *) annna-say '✺◟( ° ʖ °)◞✺';;
          927         esac;;
          928 "${IRC_USER}, please give me a fish"*)
          929         case "$(($RANDOM % 2))" in
          930         0) annna-say '<><';;
          931         *) annna-say '><>';;
          932         esac;;
          933 "${IRC_USER}, run"*) annna-say 'ᕕ(ಠ_ಠ)ᕗ';;
          934 "${IRC_USER}, be cute"*)
          935         case "$(($RANDOM % 4))" in
          936         0)      annna-say '    (\ /)' && sleep 0.1
          937                 annna-say '    (. .)' && sleep 0.1
          938                 annna-say '  C(") (")';;
          939         1)      annna-say '   (\-/)' && sleep 0.1
          940                 annna-say "  (='.'=)" && sleep 0.1
          941                 annna-say '  (")-(")o';;
          942         2)      annna-say '  ( ) ( )' && sleep 0.1
          943                 annna-say '  (>•.•<)' && sleep 0.1
          944                 annna-say '  (") (")' && sleep 0.1;;
          945         *)      annna-say '  (\  (\' && sleep 0.1
          946                 annna-say "  (=' :')" && sleep 0.1
          947                 annna-say '  (, (") (")';;
          948         esac;;
          949 "${IRC_USER}, 8ball "*)
          950         eightballanswer="$(8ball)"
          951         [ -n "${eightballanswer}" ] && annna-say "${eightballanswer}";;
          952 "${IRC_USER}, email "*)
          953         findsyou="$(shuf -n 1 "${ANNNA_MODBASE}/finds-you/finds_you.txt")"
          954         [ -n "${findsyou}" ] && annna-say "${IRC_CMD_USER}, I hope this email ${findsyou}";;
          955 "${IRC_USER}, please throw a coin for me.")
          956         case "$((($RANDOM % 2) + 1))" in
          957         1) annna-say "face";;
          958         2) annna-say "number";;
          959         esac;;
          960 "${IRC_USER}, please quantum roll d2 for me"*)
          961         qroll="$(($(/home/20h/scm/quantum-rng/quantum-rng) + 1))"
          962         annna-say "${IRC_CMD_USER}, ${qroll} [1d2(scores:[${qroll}])]";;
          963 "${IRC_USER}, please roll "*" for me"*)
          964         q="${text#* roll }"
          965         q="${q%for*}"
          966 
          967         # https://en.wikipedia.org/wiki/Dice_notation
          968         # six-sided dice one time
          969         [ -z "${q}" ] && q="d6"
          970         [ "${q}" = "a die " ] && q="d6"
          971         [ "${q}" = "dice " ] && q="d6"
          972 
          973         dicescore="$(dice "${q}")"
          974         annna-say "${IRC_CMD_USER}, ${dicescore}";;
          975 "${IRC_USER}, please tell me your favourite flower"*) annna-say "My favourite flower is the beer flower.";;
          976 "${IRC_USER}, please tell me your favourite color"*) annna-say "My favourite color is yellow.";;
          977 "${IRC_USER}, please clap for me"*) annna-say "${IRC_CMD_USER}, *clap* *clap* *clap*";;
          978 "${IRC_USER}, which city does not exist?")
          979         cityuri="$(this-city-does-not-exist)"
          980         if [ -n "${cityuri}" ];
          981         then
          982                 annna-say "${IRC_CMD_USER}, this one: ${cityuri}"
          983         else
          984                 annna-say "${IRC_CMD_USER}, none."
          985         fi;;
          986 [Ff]"or humanity"*) annna-say "${IRC_CMD_USER}, for humanity! gophers://bitreich.org/0/memecache/annna-rchism.txt";;
          987 [Hh]"ack the planet"*) annna-say "${IRC_CMD_USER}, hack the planet!" ;;
          988 [Ll]"ong live gopher"*) annna-say "${IRC_CMD_USER}, long live gopher!";;
          989 ":)"|":))"|":)))"|":-)"|":-))"|":-)))"|":--)"|":--))"|":--)))"|":---)"|":----)"|"llol"|"lllol") annna-say -- "$(smile)";;
          990 "${IRC_USER}, please dance."|"\\o/"|"\^o^/") annna-say -- "$(dance-moves-gen)";;
          991 "${IRC_USER}, let us celebrate!"|"/o/"|"\o\\") annna-say -- "$(dance-moves-gen -m)";;
          992 "${IRC_USER}, please egyptian dance."|"${IRC_USER}, let us egyptian celebrate!"|"~o~"|"|o|") annna-say -- "$(dance-moves-gen -e)";;
          993 "${IRC_USER}, please stamp this letter for me"*) annna-say -- "${IRC_CMD_USER}, here: 🖃 ";;
          994 "${IRC_USER}, please do the graveyard smash"*)
          995         annna-say -- "( つ ・ᴗ・)つ"
          996         annna-say -- "ς ( ・ᴗ・ ς )"
          997         annna-say -- "It did the mash\\ It did the ~~MONSTER MASH~~\\ It was a smash\\ It was a ~~GRAVEYARD SMASH~~";;
          998 "${IRC_USER}, boo"*) annna-say "${IRC_CMD_USER}, 👻";;
          999 "${IRC_USER}, W3C"*|"${IRC_USER}, w3c"*) annna-say "${IRC_CMD_USER}, 🕸️ 🕷️ 🕸️";;
         1000 "${IRC_USER}, pumpkin"*) annna-say "${IRC_CMD_USER}, 🎃";;
         1001 "${IRC_USER}, trick or treat"*|"${IRC_USER}, treat or trick"*)
         1002         annna-say "Wait for it. Old annnama is searching ..."
         1003         {
         1004                 sleeptime="$(( $RANDOM % 120 + 10 ))"
         1005                 if [ $sleeptime -gt 60 ];
         1006                 then
         1007                         sleep "$(( $RANDOM % 30 + 20 ))"
         1008                         annna-say "${IRC_CMD_USER}, *swish* *swish* old annnama is still searching."
         1009                         sleeptime="$(( $RANDOM % 60 + 10 ))"
         1010                 fi
         1011                 sleep $sleeptime
         1012 
         1013                 annna-say "${IRC_CMD_USER}, $(trick-or-treat)"
         1014         } & ;;
         1015 "${IRC_USER}, please dance with me"*)
         1016         if [ $(($RANDOM % 2)) -gt 0 ];
         1017         then
         1018                 annna-say "I am not that kind of woman."
         1019         else
         1020                 annna-say "Thank you! Let us dance! :-D"
         1021         fi;;
         1022 "${IRC_USER}, please tell me who is your favourite pleasure man"*) annna-say "My favourite pleasure man is of course Gunther!";;
         1023 "${IRC_USER}, make me a sandwich"*) annna-say "No.";;
         1024 "${IRC_USER}, sudo make me a sandwich"*) annna-say "Humans are no objects.";;
         1025 "${IRC_USER}, please make me a sandwich"*) annna-say "Maybe.";;
         1026 "${IRC_USER}, sudo please make me a sandwich"*) annna-say "Here is your sandwich.";;
         1027 "${IRC_USER}, I feel unsure about my health.")
         1028         healthadvice="$(health-advice)"
         1029         [ -n "${healthadvice}" ] && annna-say "${IRC_CMD_USER}, ${healthadvice}";;
         1030 "${IRC_USER}, bonjour !") annna-say "${IRC_CMD_USER}, bonjour !";;
         1031 *" pets ${IRC_USER}"*) annna-say "${IRC_CMD_USER}, *brrrrr*";;
         1032 "${IRC_USER}, please give me a penis extension"*) annna-say "${IRC_CMD_USER}, here: $(penis-extension)";;
         1033 "${IRC_USER}, please bobbitize me"*) annna-say "${IRC_CMD_USER}, here: $(bobbitize)";;
         1034 "${IRC_USER}, please give me a baguette extension"*) annna-say "${IRC_CMD_USER}, here: $(baguette-extension)";;
         1035 "${IRC_USER}, please give me an allah extension"*) annna-say "${IRC_CMD_USER}, here: $(allah-extension)";;
         1036 "${IRC_USER}, please pull my finger"*) annna-say "${IRC_CMD_USER}, you are disgusting.";;
         1037 "${IRC_USER}, what's up in Japan?") annna-say "${IRC_CMD_USER}, see for yourself: https://nhk3.mov3.co/hls/nhk.m3u8";;
         1038 "${IRC_USER}, please mqtt"*)
         1039         mqtturi="$(printf '%s\n' "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 3)"
         1040         case "${mqtturi}" in
         1041         mqtt:*);; #mqtt:// full URI specified
         1042         *) mqtturi="mqtts://bitreich:oogui3queex&o9zaekah@bitreich.org/${mqtturi#mqtt}";;
         1043         esac
         1044         msg="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 4-)"
         1045         printf "${msg}\n" | mosquitto_pub -L "${mqtturi}" -l;;
         1046 *[Zz]"uckerberg"*) annna-say "${IRC_CMD_USER}, did you mean gophers://bitreich.org/9/memecache/mark-suckerberg.mp4 ?";;
         1047 "${IRC_USER}, please pick one of: "*)
         1048         pick="$(printf '%s\n' "${IRC_PRIVMSG_TEXT}" \
         1049                 | sed 's/.*please pick one of: //' \
         1050                 | tr ',' '\n' \
         1051                 | tr -d ' ' \
         1052                 | sort -R \
         1053                 | head -n 1)"
         1054         annna-say "${IRC_CMD_USER}, I think ${pick} is the best option.";;
         1055 "${IRC_USER}, please play some Bach"*)
         1056         midifile="$(find . /home/annna/bin/modules/midi-media/bach -name '*.mid' \
         1057                 | sort -R \
         1058                 | head -n 1)"
         1059         outfile="/br/gopher/midi/${midifile##*/}.ogg"
         1060         midi-play "$midifile" >"$outfile" && annna-say "${IRC_CMD_USER}, gophers://bitreich.org/9/midi/${outfile##*/}";;
         1061 "${IRC_USER}, please 3d "*)
         1062         args=$(echo ${IRC_PRIVMSG_TEXT} | cut -d' ' -f 4-)
         1063         outfile=$(blender-effect $args)
         1064         annna-say "${IRC_CMD_USER}, gophers://bitreich.org/I/memecache/3d/${outfile}";;
         1065 # https://ednaundharvey.fandom.com/de/wiki/Droggelbecher
         1066 "${IRC_USER}, droggelbecher"*) annna-say "${IRC_CMD_USER}, Droggelbecher!";;
         1067 "${IRC_USER}, thanks"*|"${IRC_USER}, thx"*) annna-say "${IRC_CMD_USER}, you're welcome.";;
         1068 "${IRC_USER}, please simulate "*" simulator"*)
         1069         q="${IRC_PRIVMSG_TEXT#* please simulate }"
         1070         q="${q% simulator*}"
         1071         outpath="/br/gopher/p/"
         1072         {
         1073                 if outfile="$(simulate-simulator "$q")"
         1074                 then
         1075                         mv "${outfile}" "${outpath}/"
         1076                         annna-say "${IRC_CMD_USER}, gophers://bitreich.org/I/p/${outfile}"
         1077                 fi
         1078         } & ;;
         1079 "${IRC_USER}, can "*" certify itself?")
         1080         q="${IRC_PRIVMSG_TEXT#* can }"
         1081         q="${q% certify*}"
         1082         {
         1083                 # host:port is needed for tlsgrab
         1084                 curi="$(tlsgrab "${q}")"
         1085                 if [ -n "${curi}" ];
         1086                 then
         1087                         annna-say "${IRC_CMD_USER}, let us see the certificate: ${curi}"
         1088                 fi
         1089         } & ;;
         1090 "${IRC_USER}, please mine "*" bitreichcoin"*)
         1091         q="${IRC_PRIVMSG_TEXT#* please mine }"
         1092         q="${q% bitreichcoin*}"
         1093         curi="$(bitreichcoin "$q" | /br/bin/bitreich-paste)"
         1094         annna-say "${IRC_CMD_USER}, please don't spend it all at once: ${curi}";;
         1095 "${IRC_USER}, please hug me.") annna-say "$(echo -e '\001')ACTION hugs ${IRC_CMD_USER}$(echo -e '\001')";;
         1096 "${IRC_USER}, please hug "*" for me.")
         1097         huggee="${IRC_PRIVMSG_TEXT#* please hug }"
         1098         huggee="${huggee% for me*}"
         1099         [ -n "${huggee}" ] && annna-say "$(echo -e '\001')ACTION hugs ${huggee}$(echo -e '\001')";;
         1100 "${IRC_USER}, how many fucks were given?") annna-say "${IRC_CMD_USER}, current fucks given: 0.0";;
         1101 "${IRC_USER}, please slam the door.") annna-say "${IRC_CMD_USER}, *BANG*";;
         1102 "${IRC_USER}, what is my credit score?") annna-say "${IRC_CMD_USER}, your credit score is 0.";;
         1103 "${IRC_USER}, please give me a cookie.")
         1104         cookie="$(cookie)"
         1105         [ -n "${cookie}" ] && annna-say "$(echo -e '\001')ACTION gives ${IRC_CMD_USER} a ${cookie} cookie$(echo -e '\001')";;
         1106 "${IRC_USER}, please help"*) annna-say -c "${IRC_CMD_USER}" "See git://bitreich.org/annna for my commands.";;
         1107 "${IRC_USER}, please meme meme meme me"*)
         1108         randomtag=2
         1109         while [ $randomtag -gt 0 ];
         1110         do
         1111                 rtag="$(printf "%s\n" "$(hashtags)" | shuf -n 1)"
         1112                 tagname=""
         1113                 taguri=""
         1114                 for tag in ${rtag};
         1115                 do
         1116                         [ -z "${tagname}" ] && tagname="${tag}" && continue
         1117                         taguri="${tag}"
         1118                 done
         1119                 annna-say "${tagname}: ${taguri}"
         1120                 randomtag=$((randomtag - 1))
         1121         done;;
         1122 "${IRC_USER}, what's the wheelchair shooter meme again?")
         1123         tagname="#scrollby"
         1124         tagline="$(printf "%s\n" "$(hashtags)" | grep "^${tagname} ")"
         1125         tagname="$(printf "%s\n" "${tagline}" | cut -d ' ' -f 1)"
         1126         taguri="$(printf "%s\n" "${tagline}" | cut -d ' ' -f 2-)"
         1127         annna-say "${tagname}: ${taguri}";;
         1128 "${IRC_USER}, TIL "*|"${IRC_USER}, til "*)
         1129         minimum_learned_len=12
         1130         offset=$(( ${#IRC_USER} + 6 ))
         1131         learned="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" \
         1132                 | cut -c $offset- \
         1133                 | sed 's,\t,    ,g')"
         1134         if [ ${#learned} -le $minimum_learned_len ];
         1135         then
         1136                 annna-say "${IRC_CMD_USER}, can you explain better what you learned?"
         1137         else
         1138                 result="$(til ${IRC_CMD_USER} "${learned}")"
         1139                 if [ $? -eq 0 ];
         1140                 then
         1141                         annna-say "${IRC_CMD_USER}, ${result}"
         1142                 fi
         1143         fi;;
         1144 "${IRC_USER}, what have I learned?")
         1145         if result=$(til-user ${IRC_CMD_USER});
         1146         then
         1147                 annna-say "${IRC_CMD_USER}, ${result}"
         1148         fi;;
         1149 esac
         1150 
         1151 for person in "${!personalities[@]}";
         1152 do case "${IRC_PRIVMSG_TEXT,,}" in
         1153 "${person}, "*)
         1154         personality="${personalities[${person}]}"
         1155         preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.txt)"
         1156         prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 2- | sed 's,\t,    ,g')"
         1157         annna-say "$(gpt "System: ${preprompt}\n User: ${prompt}\n Bot:")" &
         1158 esac done
         1159 
         1160 case "${IRC_PRIVMSG_TEXT}" in
         1161 "${IRC_USER}, please antidepressant #"*|\
         1162 "${IRC_USER}, please amplify #"*|\
         1163 "${IRC_USER}, please amsterdamify #"*|\
         1164 "${IRC_USER}, please banjo #"*|\
         1165 "${IRC_USER}, please bounce #"*|\
         1166 "${IRC_USER}, please breakingnews #"*|\
         1167 "${IRC_USER}, please celtify #"*|\
         1168 "${IRC_USER}, please concatenate #"*|\
         1169 "${IRC_USER}, please crimetv #"*|\
         1170 "${IRC_USER}, please curb #"*|\
         1171 "${IRC_USER}, please daybowbow #"*|\
         1172 "${IRC_USER}, please deathmetal #"*|\
         1173 "${IRC_USER}, please developers #"*|\
         1174 "${IRC_USER}, please dontdoit #"*|\
         1175 "${IRC_USER}, please dontsaytoyourmother #"*|\
         1176 "${IRC_USER}, please doomify #"*|\
         1177 "${IRC_USER}, please dutchapprove #"*|\
         1178 "${IRC_USER}, please french #"*|\
         1179 "${IRC_USER}, please FRENCH #"*|\
         1180 "${IRC_USER}, please imam #"*|\
         1181 "${IRC_USER}, please lop #"*|\
         1182 "${IRC_USER}, please loop #"*|\
         1183 "${IRC_USER}, please looop #"*|\
         1184 "${IRC_USER}, please loooop #"*|\
         1185 "${IRC_USER}, please mow #"*|\
         1186 "${IRC_USER}, please namflashback #"*|\
         1187 "${IRC_USER}, please news #"*|\
         1188 "${IRC_USER}, please pullmyfinger #"*|\
         1189 "${IRC_USER}, please putin #"*|\
         1190 "${IRC_USER}, please reverse #"*|\
         1191 "${IRC_USER}, please richardstrauss #"*|\
         1192 "${IRC_USER}, please ritual #"*|\
         1193 "${IRC_USER}, please sadviolin #"*|\
         1194 "${IRC_USER}, please science #"*|\
         1195 "${IRC_USER}, please scrollify #"*|\
         1196 "${IRC_USER}, please sendtohell #"*|\
         1197 "${IRC_USER}, please sexify #"*|\
         1198 "${IRC_USER}, please slavify #"*|\
         1199 "${IRC_USER}, please slowdown #"*|\
         1200 "${IRC_USER}, please smith #"*|\
         1201 "${IRC_USER}, please speedup #"*|\
         1202 "${IRC_USER}, please techno #"*|\
         1203 "${IRC_USER}, please technodrugs #"*|\
         1204 "${IRC_USER}, please thin #"*|\
         1205 "${IRC_USER}, please torture #"*|\
         1206 "${IRC_USER}, please tshirt #"*|\
         1207 "${IRC_USER}, please trumpapprove #"*|\
         1208 "${IRC_USER}, please USAUSA #"*|\
         1209 "${IRC_USER}, please USA #"*|\
         1210 "${IRC_USER}, please usa #"*|\
         1211 "${IRC_USER}, please wat #"*|\
         1212 "${IRC_USER}, please widen #"*|\
         1213 "${IRC_USER}, please ww1 #"*|\
         1214 "${IRC_USER}, please yellow #"*|\
         1215 "${IRC_USER}, please zucc #"*|\
         1216 "${IRC_USER}, please random #"*)
         1217         hashtag="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | sed 's/.*#//; s/ .*//' )"
         1218         recipient="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | sed 's/.* for //' )"
         1219         [ -z "${recipient}" ] && recipient="${IRC_CMD_USER}"
         1220         origext="$(grep -E "^#${hashtag} " "${hashtagfile}" | sed 's/.*\.//')"
         1221         {
         1222                 filter="$(printf '%s\n' "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f3)"
         1223                 if [ "${filter}" = "random" ];
         1224                 then
         1225                         filters=("antidepressant" "amplify" "amsterdamify"
         1226                                  "banjo" "bounce" "breakingnews"
         1227                                  "celtify" "concatenate" "crimetv"
         1228                                  "curb" "daybowbow" "deathmetal"
         1229                                  "developers" "dontdoit" "dontsaytoyourmother"
         1230                                  "doomify" "dutchapprove" "french"
         1231                                  "FRENCH" "imam" "lop" "loop" "looop" "loooop"
         1232                                  "mow" "namflashback" "news"
         1233                                  "pullmyfinger" "putin" "reverse"
         1234                                  "richardstrauss" "ritual" "sadviolin"
         1235                                  "science" "scrollify" "sendtohell"
         1236                                  "sexify" "slavify" "slowdown"
         1237                                  "smith" "speedup" "techno"
         1238                                  "technodrugs" "thin" "torture"
         1239                                  "tshirt" "trumpapprove" "USAUSA"
         1240                                  "usa" "wat" "widen" "ww1"
         1241                                  "yellow" "zucc")
         1242                         filter="${filters[ $RANDOM % ${#filters[@]} ]}"
         1243                 fi
         1244                 outfile="${filter}-${hashtag}.mkv"
         1245                 outpath="/br/gopher/memecache/filter/${outfile}"
         1246                 inpath="/br/gopher/memecache/${hashtag}.${origext}"
         1247 
         1248                 [ ! -f "${inpath}" ] && exit 0
         1249 
         1250                 # outfile and outpath filtering for the cache.
         1251                 case "${filter}" in
         1252                 antidepressant|ritual|putin|tshirt)
         1253                         outfile="${outfile%.*}.jpg"
         1254                         outpath="${outpath%.*}.jpg";;
         1255                 wat|smith|zucc)
         1256                         mimetype="$(file --mime-type "$inpath" | cut -d':' -f 2 | cut -c 2-)"
         1257                         # Only allow images to be free.
         1258                         case "$mimetype" in
         1259                         image/webp)
         1260                                 # deface does not like webp. Make it png.
         1261                                 newinpath="$(mktemp -u -p /tmp "${infile%.*}XXXXX.png")"
         1262                                 magick "${inpath}" "${newinpath}" >/dev/null 2>&1
         1263                                 inpath="${newinpath}"
         1264 
         1265                                 outfile="${outfile%.*}.png"
         1266                                 outpath="${outpath%.*}.png";;
         1267                         image/*)
         1268                                 outfile="${outfile%.*}.${origext}"
         1269                                 outpath="${outpath%.*}.${origext}";;
         1270                         esac
         1271                 esac
         1272                 # Cleanup if outpath file is empty.
         1273                 [ -f "${outpath}" ] && [ ! -s "${outpath}" ] && rm "${outpath}"
         1274 
         1275                 # determine gopher type for output file
         1276                 outmimetype="$(file -ib "${outpath}")"
         1277                 case "$outmimetype" in
         1278                 image/*) outtype="I";;
         1279                 *) outtype="9";;
         1280                 esac
         1281 
         1282                 if [ -s "${outpath}" ];
         1283                 then
         1284                         annna-say "${recipient}, gophers://bitreich.org/${outtype}/memecache/filter/${outfile}"
         1285                         exit 0
         1286                 fi
         1287 
         1288                 case "${filter}" in
         1289                 antidepressant) antidepressant "${inpath}" "${outpath}" >/dev/null 2>&1;;
         1290                 ritual) satanic-ritual "${inpath}" "${outpath}" >/dev/null 2>&1;;
         1291                 putin) putin-os "${inpath}" "${outpath}" >/dev/null 2>&1;;
         1292                 tshirt) tshirt-design "${inpath}" "${outpath}" >/dev/null 2>&1;;
         1293                 *) ffmpeg-effect "${filter}" "${inpath}" "${outpath}" >/dev/null 2>&1;;
         1294                 esac
         1295 
         1296                 # Remove temporary png for deface.
         1297                 case "${inpath}" in
         1298                 /tmp/*.png) [ -e "${inpath}" ] && rm "${inpath}";;
         1299                 esac
         1300 
         1301                 [ -s "${outpath}" ] && annna-say "${recipient}, gophers://bitreich.org/${outtype}/memecache/filter/${outfile}"
         1302         } &
         1303         exit 0;;
         1304 esac
         1305 
         1306 printf '%s' "${IRC_PRIVMSG_TEXT}" | awk -v taglimit="$printnhashtags" '
         1307 $0 !~ /#nospoil/ {
         1308         while (match($0, /[#*&]+[^# /"'\'',?!;$\001]+/)) {
         1309                 tag = substr($0, RSTART, RLENGTH)
         1310                 $0 = substr($0, RSTART + RLENGTH)
         1311                 sub(/[.]*$/, "", tag)
         1312                 if (!uniq[tag]++ && taglimit-- > 0)
         1313                         print tag
         1314         }
         1315 }' | head -n "$printnhashtags" | while read -r tag;
         1316 do
         1317         [ "${tag}" = "#expand" ] && continue
         1318 
         1319         origtag="${tag}"
         1320         pointer=0
         1321         revpointer=0
         1322         case "${tag}" in
         1323         "*"*)   tag="#$(printf "%s\n" "${tag}" | sed "s,^[\*]*,,")"
         1324                 pointer=1;;
         1325         "&"*)   tag="#$(printf "%s\n" "${tag}" | sed "s,^[\&]*,,")"
         1326                 revpointer=1;;
         1327         esac
         1328 
         1329         tagline="$(grep "${tag} " "${hashtagfile}" | shuf -n 1)";
         1330         if [ -n "${tagline}" ];
         1331         then
         1332                 if [ $nospoil -eq 0 ];
         1333                 then
         1334                         if [ $pointer -eq 1 ];
         1335                         then
         1336                                 inpath="/br/gopher/memecache/${tagline##*/}"
         1337                                 [ ! -f "${inpath}" ] && exit 0
         1338 
         1339                                 outfile="${tag#\#}.jpg"
         1340                                 # pointy pointers
         1341                                 outpath="$(printf "%s\n" "${origtag}" \
         1342                                 | sed 's,\*,&\n,g' \
         1343                                 | grep "^*" \
         1344                                 | while read -r asterisk;
         1345                                 do
         1346                                         outfile="*${outfile}"
         1347                                         outpath="/br/gopher/memecache/filter/${outfile}"
         1348                                         printf "%s\n" "${outpath}"
         1349                                         if [ -e "${outpath}" ];
         1350                                         then
         1351                                                 inpath="${outpath}";
         1352                                                 continue
         1353                                         fi
         1354                                         pointer "${inpath}" "${outpath}" >/dev/null 2>&1;
         1355                                         inpath="${outpath}";
         1356                                 done | tail -n 1)"
         1357 
         1358                                 if [ -e "${outpath}" ];
         1359                                 then
         1360                                         outfile="$(basename "${outpath}")"
         1361                                         annna-say "${origtag}: gophers://bitreich.org/9/memecache/filter/${outfile}"
         1362                                 fi
         1363                         elif [ $revpointer -eq 1 ];
         1364                         then
         1365                                 inpath="/br/gopher/memecache/${tagline##*/}"
         1366                                 [ ! -f "${inpath}" ] && exit 0
         1367 
         1368                                 outfile="${tag#\#}.jpg"
         1369                                 # pointy pointers
         1370                                 outpath="$(printf "%s\n" "${origtag}" \
         1371                                 | sed 's,\&,&\n,g' \
         1372                                 | grep "^&" \
         1373                                 | while read -r asterisk;
         1374                                 do
         1375                                         outfile="&${outfile}"
         1376                                         outpath="/br/gopher/memecache/filter/${outfile}"
         1377                                         printf "%s\n" "${outpath}"
         1378                                         if [ -e "${outpath}" ];
         1379                                         then
         1380                                                 inpath="${outpath}";
         1381                                                 continue
         1382                                         fi
         1383                                         revpointer "${inpath}" "${outpath}" >/dev/null 2>&1;
         1384                                         inpath="${outpath}";
         1385                                 done | tail -n 1)"
         1386 
         1387                                 if [ -e "${outpath}" ];
         1388                                 then
         1389                                         outfile="$(basename "${outpath}")"
         1390                                         annna-say "${origtag}: gophers://bitreich.org/9/memecache/filter/${outfile}"
         1391                                 fi
         1392                         else
         1393                                 annna-say "${tagline% *}: ${tagline#* }"
         1394                         fi
         1395                 fi
         1396         else
         1397                 if [ $doexpand -eq 1 ];
         1398                 then
         1399                         taglength=$(utf8expr length "${tag}")
         1400                         if [ $uriexpansion -eq 0 ] && [ $taglength -gt 3 ];
         1401                         then
         1402                                 didyoumean="$(annna-meme-recommend "${tag}")"
         1403                                 if [ -n "${didyoumean}" ];
         1404                                 then
         1405                                         annna-say "Did you mean: ${didyoumean}?"
         1406                                 fi
         1407                         fi
         1408                 fi
         1409         fi
         1410 done
         1411 
         1412 case "${IRC_PRIVMSG_TEXT,,}" in
         1413 *\#nospoil*);;
         1414 *rfc[0-9]*)
         1415         rfcname="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | sed 's,.*\(rfc[0-9]*\).*,\1,')"
         1416         annna-say "${rfcname}: ftp://ftp.rfc-editor.org/in-notes/${rfcname}.txt";;
         1417 esac
         1418 
         1419 # Always keep the karma / shame last!
         1420 case "${IRC_PRIVMSG_TEXT}" in
         1421 *"-shaming"*)
         1422         shametext="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | sed 's,.* \(.*-shaming\).*,\1,')"
         1423         shame "${shametext}" >/dev/null;;
         1424 *"arma is a bitch"*) annna-say "${IRC_CMD_USER}, I object! Karma is a nice girl!";;
         1425 # For referee scoring.
         1426 "score "*);;
         1427 *++|*--|*-=?|*+=?|*+=-?|*-=-?)
         1428         karmatext="$(karma "${IRC_PRIVMSG_TEXT}")"
         1429         [ -n "$karmatext" ] && annna-say "karma: ${karmatext}";;
         1430 esac
         1431 
         1432 # Membership Level.
         1433 ismember=0
         1434 for member in $brmembers;
         1435 do
         1436         [ "${IRC_CMD_USER}" = "${member}" ] && ismember=1
         1437 done
         1438 [ $ismember -lt 1 ] && exit
         1439 
         1440 case "${IRC_PRIVMSG_TEXT}" in
         1441 "${IRC_USER}, please go to sleep.")
         1442         annna-say "Going to sleep ... Zzzz ..."
         1443         annna-sleep-well;;
         1444 "${IRC_USER}, please wake up.")
         1445         annna-wakeup
         1446         annna-say "Good morning BITREICH!";;
         1447 "${IRC_USER}, can you show me the uptime please?") annna-say "$(hostname) uptime: $(uptime)";;
         1448 "${IRC_USER}, please show me the load.") annna-say "$(hostname) load: $(LANG=C uptime | sed 's,.*load average: \(.*\)$,\1,')";;
         1449 "${IRC_USER}, please give me the count of online users.") annna-say "$(hostname): $(who -q | tail -n 1 | cut -d'=' -f 2)";;
         1450 "${IRC_USER}, please update the phlog index.")
         1451         phlog-index > /dev/null 2>&1
         1452         annna-say "Thanks! Your request has been fulfilled with the quickness! :)";;
         1453 esac
         1454 
         1455 # Referee Level.
         1456 isreferee=0
         1457 for referee in $referees;
         1458 do
         1459         [ "$user" = "$referee" ] && isreferee=1
         1460 done
         1461 [ $isreferee -lt 1 ] && exit
         1462 
         1463 case "${IRC_PRIVMSG_TEXT}" in
         1464 "score "*)
         1465         text="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f2-)"
         1466         case "${IRC_PRIVMSG_TEXT}" in
         1467         *++|*--|*-=?|*+=?|*+=-?|*-=-?|*-=??|*+=??|*-=-??|*-=65536*)
         1468                 scoretext="$(brcon-score "${IRC_PRIVMSG_TEXT}")"
         1469                 [ -n "$scoretext" ] && annna-say "brcon score: ${scoretext}";;
         1470         esac;;
         1471 esac
         1472