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