split channel-specific content to its own script - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit aea4bdf3acd506f2486022fac38f2cd7ea3d1c86 DIR parent 943d44215057ce4f29d99c06c30be236fcfff065 HTML Author: Josuah Demangeon <mail@josuah.net> Date: Mon, 8 Mar 2021 00:41:11 +0100 split channel-specific content to its own script Signed-off-by: Annna Robert-Houdin <annna@bitreich.org> Diffstat: A annna-message-common | 765 +++++++++++++++++++++++++++++++ A annna-message-radio | 24 ++++++++++++++++++++++++ M annna-start-services | 791 +------------------------------ 3 files changed, 791 insertions(+), 789 deletions(-) --- DIR diff --git a/annna-message-common b/annna-message-common @@ -0,0 +1,765 @@ +#!/bin/sh +# +# If this gets too unmaintainable, consider adding some directory structure. +# + +modbase="/home/annna/bin/modules/" +hashtagfile="${modbase}/hashtags/hashtags.txt" +printnhashtags=2 +botname="annna" + +channel="$1" +user="$2" +text="$3" + +hashtags() { + cat ${hashtagfile} 2>/dev/null +} + +hashtagcount() { + int2bit "$(wc -l ${hashtagfile} | cut -d' ' -f 1)" +} + +regeximatch() { + printf '%s' "$1" | grep -i -E -q "$2" +} + +printf "%s %s %s %s\n" "${0##*/}" "${channel}" "${user}" "${text}" + +[ "$user" = "${botname}" ] && exit + +uri="$(printf "%s\n" "${text}" \ + | sed -n '/.*\(https\{0,1\}:\/\/[^ ]\{1,\}\).*/s//\1/p')" +case "${text}" in +*\#nospoil*) + ;; +*) + if [ -n "${uri}" ] + then + tmpf=$(mktemp) + fetch-uri "${uri}" > "${tmpf}" + urititle="$(grabtitle < "${tmpf}")" + + # Set below and annna will concatenate at the end. + # Subtitle URI. + sturi="" + # Replacement URI. + nuri="" + # Replacement URI display string. + nuris="" + # html2text content. + curi="" + # Set to 0, if some URI content should be shown. + nocuri=1 + # Screenshot. + suri="" + + # titleend=1 will not output any further. + titleend=0 + outputstr="" + + if [ -n "$urititle" ]; + then + case "${urititle}" in + *Gunther*|*GUNTHER*|*Günther*) + annna-say -c "${channel}" "Oh Gunther! ⤠⤠⤠${urititle}" + ;; + *\|\ Cloudflare*) + annna-say -c "${channel}" "Mind your own business! We got clownflared: gopher://bitreich.org/0/ascii/clownflare.vt" + titleend=1 + ;; + esac + fi + + case "${uri}" in + *youtube.com/*|*youtu.be/*) + nuri="https://invidious.13ad.de/${uri#https*://*/}" + fetch-uri "${nuri}" > "${tmpf}" + urititle="$(curl-grabtitle "${nuri}")" + sturi="$(subtitle-paste "${uri}")" + nuris="invidious: ${nuri}" + nocuri=0 + ;; + *twitter.com*) + ninstance="$(nitter-instance | sed 's,\.,\\\.,g')" + nuri="$(printf "%s\n" "${uri}" | sed "s;\(mobile\.\)\{0,1\}twitter\.com;${ninstance};")" + fetch-uri "${nuri}" > "${tmpf}" + urititle="$(curl-grabtitle "${nuri}")" + suri="$(screenshot-paste "${nuri}")" + nuris="nitter: ${nuri}" + nocuri=0 + ;; + *en.wikipedia.org/wiki*) + if ! regeximatch "$uri" '\.(jpg,bmp,gif,png,tiff,avi,mp4,webm,mkv,pdf,ps,eps)$'; + then + nuri="$(printf '%s\n' "${uri}" | sed -e "s;.*en.wikipedia.org/wiki;gopher://gopherpedia.com/0;" -e "s;#.*$;;")" + nuris="$(printf 'gopherpedia: %s\n' "${nuri}")" + fetch-uri "${nuri}" > "${tmpf}" + nocuri=0 + fi + ;; + *www.reddit.com*) + nuri="$(printf '%s\n' "${uri}" | sed "s;www.reddit.com;old.reddit.com;")" + nuris="old.reddit: ${nuri}" + fetch-uri "${nuri}" > "${tmpf}" + if [ -n "${uri#*www.reddit.com/r/*}" ]; + then + subreddit="$(printf '%s\n' "${uri}" | cut -d / -f 5)" + post="$(printf '%s\n' "${uri}" | cut -d / -f 7)" + if [ -n "${post}" ]; + then + guri="gopher://gopherddit.com/1/cgi-bin/reddit.cgi?view&${post}&${subreddit}&10" + else + guri="gopher://gopherddit.com/1/cgi-bin/reddit.cgi?menu&${subreddit}&10" + fi + nuris="${nuri} ; gopherdit: ${guri}" + fi + nocuri=0 + ;; + *github.com/*/blob/*) + urltitle="" + nuris="$(printf '%s' "${uri}" | sed 's/blob/raw/')" + nocuri=0 + ;; + *www.npr.org/*) + post="$(printf '%s\n' "${uri}" | cut -d / -f 7)" + if [ -n "${post}" ]; + then + nuri="https://text.npr.org/s.php?sId=${post}" + nuris="text only: ${nuri}" + fi + ;; + *) + mimetype="$(file -b --mime-type "${tmpf}")" + case "${mimetype}" in + text/*) + nocuri=0 + ;; + esac + ;; + esac + + if [ $titleend -eq 0 ]; + then + if [ $nocuri -eq 0 ]; + then + if [ -z "${curi}" ]; + then + curi="$(9 htmlfmt < "${tmpf}" | /br/bin/bitreich-paste)" + fi + outputstr="${outputstr} content: ${curi} ;" + fi + + [ -n "${nuris}" ] && outputstr="${outputstr} ${nuris} ;" + [ -n "${urititle}" ] && outputstr="${outputstr} title: ${urititle} ;" + [ -n "${suri}" ] && outputstr="${outputstr} screen: ${suri} ;" + [ -n "${sturi}" ] && outputstr="${outputstr} subtitles: ${sturi} ;" + annna-say -c "${channel}" "${outputstr}" + fi + rm -f "${tmpf}" + fi + ;; +esac + +case "${text}" in +"${botname}, how can I phlog on bitreich?") + annna-say -c "${channel}" "${user}, please read: gopher://bitreich.org/0/usr/20h/phlog/2017-08-26T20-04-02-482296.md and gopher://bitreich.org/0/usr/20h/phlog/2017-08-26T20-27-40-281825.md" + ;; +"${botname}, what is "*) + word="$(printf "%s\n" "${text}" | cut -c 16-)" + case "$word" in + *\?) + word="$(printf "%s\n" "${word}" | cut -c -"$(($(expr length "${word}") - 1))")" + ;; + esac + + case "${word}" in + "love") + puri="$(clippy-say "Baby don't hurt me no more!")" + ;; + "my horoscope") + puri="$(clippy-say "Did you mean _what's my horoscope?_?")" + ;; + "my horoscope") + puri="$(clippy-say "Did you mean _what's my future?_?")" + ;; + "up") + puri="$(clippy-say "Did you mean _what's up?_?")" + ;; + *) + puri="" + dresult="$(dict -h parazyd.org "${word}" 2>/dev/null)" + derr=$? + if [ $derr -eq 20 ]; + then + dresult="$(dict -h parazyd.org "${word}" 2>/dev/null)" + derr2="$?" + [ $derr2 -ne $derr ] && derr=$derr2 + fi + case "$derr" in + 0|21) + puri="$(printf "%s" "${dresult}" | /br/bin/bitreich-paste)" + ;; + 20) + puri="No matches found." + ;; + 1) + puri="Parse error." + ;; + *) + puri="Parazyd destroyed the server. Nothing to see here." + ;; + esac + esac + annna-say -c "${channel}" "${puri}" + ;; +"${botname}, cowsay "*) + word="$(printf "%s\n" "${text}" | cut -c 15-)" + tmpf=$(mktemp) + cowsayasaservice ${word} > ${tmpf} + if [ $? -eq 0 ]; then + curi="$(/br/bin/bitreich-paste < ${tmpf})" + annna-say -c "${channel}" "${user}: the cow said... ${curi}" + fi + rm ${tmpf} 2>/dev/null + ;; +"${botname}, play despacito plz.") + annna-say -c "${channel}" "${user}, gopher://bitreich.org/9/memecache/despacito.mkv" + ;; +"${botname}, please give me a Chuck Norris fact.") + chuck=$(chucknorris) + annna-say -c "${channel}" "${user}, ${chuck}" + ;; +"${botname}, please show me ip art.") + annna-say -c "${channel}" "${user}, please see #bitreich-tv for the magic." + { + cd $HOME/bin/modules/ip-art; + # Lock, so only one annna process manipulates eth0. + flock $HOME/bin/modules/ip-art -c "./display-file.sh ip-art.ipart" + } & + ;; +"${botname}, I feel stupid.") + nuri=$(darwin) + tmpf=$(mktemp) + fetch-uri "${nuri}" > "${tmpf}" + curi="$(9 htmlfmt < "${tmpf}" | /br/bin/bitreich-paste)" + annna-say -c "${channel}" "${user}, do not feel stupid, others are more stupid: ${curi}" + rm ${tmpf} 2>/dev/null + ;; +"${botname}, I feel down.") + postmortem="$(post-mortem | /br/bin/bitreich-paste)" + annna-say -c "${channel}" "${user}, do not feel bad, others had worse days: ${postmortem}" + ;; +"${botname}, will you be my girlfriend?") + rejection="$(girlfriend)" + annna-say -c "${channel}" "${user}, ${rejection}" + ;; +"${botname}, who fights crime?") + partner=$(echo $brmembers | awk '{for (i = 1; i < NF; i++) print $i}' | grep -v "^{$user}" | shuf -n 1) + crimefighter="$(theyfightcrime ${user} ${partner})" + annna-say -c "${channel}" "${crimefighter}" + ;; +"${botname}, please give me a commit message.") + commitmsg="$(whatthecommit)" + annna-say -c "${channel}" "${commitmsg}" + ;; +"${botname}, birp.") + birdname="$(bird-name)" + annna-say -c "${channel}" "${user}, I heard a ${birdname} bird." + ;; +"${botname}, please oneline me.") + randomoneliner="$(oneliner)" + if [ -z "${randomoneliner}" ]; + then + annna-say -c "${channel}" "${user}, the service failed. Please redial to your BOL account." + else + annna-say -c "${channel}" "${user}, ${randomoneliner}" + fi + ;; +"${botname}, man "*|"${botname}, man "*) + exp="$(printf "%s\n" "${text}" | cut -c 12- | sed 's,\t, ,g')" + dresult="$(COLUMNS=80 man "${exp}" 2>/dev/null)" + + if [ "$dresult" ]; + then + puri="$(printf "%s" "${dresult}" | /br/bin/bitreich-paste)" + else + puri="No matches found." + fi + + annna-say -c "${channel}" "${puri}" + ;; +"${botname}, wolfram is "*) + word="$(printf "%s\n" "${text}" | cut -c 19- | sed 's,\t, ,g')" + case "$word" in + *\?) + word="$(printf "%s\n" "${word}" | cut -c -"$(($(expr length "${word}") - 1))")" + ;; + esac + + puri="" + dresult="$(printf "/wolfram\t%s\r\n" "${word}" \ + | nc magical.fish 70 \ + | awk '/iAnswer:/,/iAsk/' \ + | grep -v '^i ' \ + | head -n -1 \ + | tail -n +2 \ + | sed 's,i\(.*\)fake\texample.com.*,\1,;s,[ \t]*$,,')" + + + if [ -n "$dresult" ]; + then + case "${dresult}" in + b*) + dresult="$(printf "%s\n" "${dresult}" \ + | tr '\n' ' ' \ + | sed "s,^b',,;s,' $,," \ + | sed 's,^b",,;s," $,,' \ + | sed 's,\\n,\n,g;s,\\t,\t,g')" + ;; + *) + dresult="$(printf "%s\n" "${dresult}" \ + | sed 's,\([a-zA-Z]\)$,\1 ,' \ + | tr -d '\n')" + ;; + esac + + wcl="$(printf "%s" "${dresult}" | wc -l)" + + if [ $wcl -gt 1 ]; + then + puri="$(printf "%s" "${dresult}" | /br/bin/bitreich-paste)" + else + puri="${dresult}" + fi + else + puri="No matches found." + fi + annna-say -c "${channel}" "${puri}" + ;; +"${botname}, pray"*) + # Emulate https://threats.kaspersky.com/en/threat/IRC-Worm.DOS.Septic/ + annna-say -c "${channel}" "${user}, I Obey my master! long live satan" + ;; +"${botname}, sacrifice"*) + # Emulate https://threats.kaspersky.com/en/threat/IRC-Worm.DOS.Septic/ + annna-say -c "${channel}" "${user}, Your word is my command, Power to satan!" + ;; +"${botname}, textsynth is "*) + word="$(printf "%s\n" "${text}" | cut -c 21- | sed 's,\t, ,g')" + case "$word" in + *\?) + word="$(printf "%s\n" "${word}" | cut -c -"$(($(expr length "${word}") - 1))")" + ;; + esac + + # Do in background, because read is very slow. + { + dresult="$(textsynth-complete -r "${word}")" + if [ -n "${dresult}" ]; + then + puri="$(printf "%s" "${dresult}" | /br/bin/bitreich-paste)" + else + puri="Textsynth did not answer." + fi + annna-say -c "${channel}" "textsynth result: ${puri}" + } & + + ;; +"${botname}, how discriminating is "*) + word="$(printf "%s\n" "${text}" | cut -c 30- | sed 's,\t, ,g')" + case "$word" in + *\?) + word="$(printf "%s\n" "${word}" | cut -c -"$(($(expr length "${word}") - 1))")" + ;; + esac + + newword="$(discrimination-filter "${word}")" + if [ "${newword}" = "${word}" ]; + then + annna-say -c "${channel}" "${user}, it is ok." + else + annna-say -c "${channel}" "${user}, it should be: ${newword}" + fi + + ;; +"${botname}, are "*) + case "${text}" in + *" in love?") + words="$(printf "%s\n" "${text}" | sed 's,.*are \(.*\) and \(.*\) in love?,\1 \2,')" + lovedistance="$(printf "%s * 100\n" "$(fstrcmp ${words})" | bc | cut -d'.' -f 1)" + if [ $lovedistance -gt 15 ]; + then + annna-say -c "${channel}" 'Yes!!! Pure <3 <3' + else + annna-say -c "${channel}" "No." + fi + ;; + esac + ;; +"Ok, ${botname}"*) + annna-say -c "${channel}" "${user}, I am not a consumer device." + ;; +"ok, ${botname}"*) + annna-say -c "${channel}" "${user}, I am not a consumer device." + ;; +"${botname}, please shoot "*) + word="$(printf "%s\n" "${text}" | cut -c 21-)" + annna-say -c "${channel}" "${word}, pew pew." + ;; +"${botname}, please flip "*) + word="$(printf "%s\n" "${text}" | cut -c 20-)" + updownword="$(updown "${word}")" + annna-say -c "${channel}" "${word} -> ${updownword}" + ;; +"${botname}, please give me a good band name.") + bandname="$(bandname-gen | shuf | head -n 1)" + annna-say -c "${channel}" "${bandname}" + ;; +"${botname}, I am horny.") + essaypaste="$(bithub-gen)" + annna-say -c "${channel}" \ + "Here is some intellectual porn for you: ${essaypaste}" + ;; +"${botname}, please turn on "*) + word="$(printf "%s\n" "${text}" | cut -c 22-)" + annna-say -c "${channel}" "â â» ${word}" + ;; +"${botname}, please turn me on.") + annna-say -c "${channel}" "â â» ${user}" + ;; +"${botname}, I'm game bored.") + gamelink="$(abandonware-random-game)" + if [ -z "${gamelink}" ]; + then + annna-say -c "${channel}" "${user}, sorry I have found nothing for you." + else + annna-say -c "${channel}" "${user}, have you tried ${gamelink} ?" + fi + ;; +"${botname}, I'm gopher bored.") + randomlink="$(/br/bin/bitreich-lawn-random-link)" + linktype="$(printf "%s\n" "${randomlink}" | cut -d '|' -f1 | cut -c2-)" + linktext="$(printf "%s\n" "${randomlink}" | cut -d '|' -f2)" + linksel="$(printf "%s\n" "${randomlink}" | cut -d '|' -f3)" + linkserver="$(printf "%s\n" "${randomlink}" | cut -d '|' -f4)" + linkport="$(printf "%s\n" "${randomlink}" | cut -d '|' -f5 | cut -d']' -f1)" + outtext="$(printf "%s - gopher://%s" "$linktext" "$linkserver")" + if [ "$linkport" != "70" -a "$linkport" != "port" ]; + then + outtext="$(printf "%s:%s" "$outtext" "$linkport")" + fi + if [ -n "$linksel" ]; + then + outtext="$(printf "%s/%s%s" "$outtext" "$linktype" "$linksel")" + fi + annna-say -c "${channel}" "$outtext" + ;; +"${botname}, wb.") + annna-say -c "${channel}" "${user}, ty! I am so happy to be here. :)" + ;; +"${botname}, welcome back.") + annna-say -c "${channel}" "${user}, thank you! I am so happy to be here. :)" + ;; +"${botname}, what's up?") + newsstr="$(ecl -shell /home/solene/gopher/bin/generator.lisp)" + annna-say -c "${channel}" "$newsstr" + ;; +"${botname}, what's down?") + annna-say -c "${channel}" "${user}, we all love you." + ;; +"${botname}, I feel sick.") + newsstr="$(cd /br/gopher/hypochondria && ./hypochondria -s random)" + annna-say -c "${channel}" "You could have ${newsstr}! Be careful!" + ;; +"${botname}, oh hai!") + annna-say -c "${channel}" "${user}, hai! How is your sex life?" + ;; +"${botname}, please tech hype me.") + techstr="$(${modbase}/markov_tech/markov)" + annna-say -c "${channel}" "${techstr}" + ;; +"${botname}, what's my horoscope?") + horostr="$($HOME/scm/bullshit/horoscope)" + annna-say -c "${channel}" "${user}, ${horostr}" + ;; +"${botname}, what's my future?") + puri="$(sacc gopher://parazyd.org/0/tarot.cgi | /br/bin/bitreich-paste)" + annna-say -c "${channel}" "${user}, your future is here: ${puri}" + ;; +"${botname}, how many memes do you know?") + annna-say -c "${channel}" "I know $(hashtagcount) memes: gopher://adamsgaard.dk/0/pub/memecount" + ;; +"${botname}, how many people died of corona?") + annna-say -c "${channel}" "${user}, too many. :( Please see yourself: gopher://magical.fish/1/covid" + ;; +"${botname}, please show me your memes.") + puri="$(printf "%s" "$(hashtags)" | /br/bin/bitreich-paste)" + annna-say -c "${channel}" "Here are my memes: ${puri}" + ;; +"${botname}, please show me the victims.") + puri="$(printf "%s" "$(hashtags)" | grep victim | /br/bin/bitreich-paste)" + annna-say -c "${channel}" "Here are the victims: ${puri}" + ;; +"${botname}, please distro-hop with me.") + ndistro="$(curl -s 'https://distrowatch.com/dwres.php?resource=popularity' \ + | grep phr2 \ + | sed 's,.*href="\(.*\)".*,\1,' \ + | sort | uniq | shuf -n 1)" + annna-say -c "${channel}" "How about https://distrowatch.com/${ndistro} ?" + ;; +"${botname}, please show me your Macron.") + annna-say -c "${channel}" "gopher://bitreich.org/0/ascii/macron.vt" + ;; +"${botname}, release the Kraken!") + annna-say -c "${channel}" "Here it is! gopher://bitreich.org/0/memecache/kraken.vt" + ;; +"${botname}, release the Quacken!") + annna-say -c "${channel}" "Quack Quack! gopher://bitreich.org/9/memecache/release-the-quacken.mkv" + ;; +"${botname}, be cool.") + case "$(($RANDOM % 4))" in + 0) + annna-say -c "${channel}" "(ââ _â )" + ;; + 1) + annna-say -c "${channel}" "(â°Ëâ¡Ëâ°)" + ;; + 2) + annna-say -c "${channel}" "(ââĹâ )Ì" + ;; + *) + annna-say -c "${channel}" "(âĹâ )" + ;; + esac + ;; +"${botname}, please cheer.") + case "$(($RANDOM % 2))" in + 0) + annna-say -c "${channel}" '~\o/~' + ;; + *) + annna-say -c "${channel}" 'âºâ( ° Ê Â°)ââº' + ;; + esac + ;; +"${botname}, be cute.") + case "$(($RANDOM % 4))" in + 0) + annna-say -c "${channel}" ' (\ /)' + sleep 0.1 + annna-say -c "${channel}" ' (. .)' + sleep 0.1 + annna-say -c "${channel}" ' C(") (")' + ;; + 1) + annna-say -c "${channel}" ' (\-/)' + sleep 0.1 + annna-say -c "${channel}" " (='.'=)" + sleep 0.1 + annna-say -c "${channel}" ' (")-(")o' + ;; + 2) + annna-say -c "${channel}" ' ( ) ( )' + sleep 0.1 + annna-say -c "${channel}" ' (>â¢.â¢<)' + sleep 0.1 + annna-say -c "${channel}" ' (") (")' + ;; + *) + annna-say -c "${channel}" ' (\ (\' + sleep 0.1 + annna-say -c "${channel}" " (=' :')" + sleep 0.1 + annna-say -c "${channel}" ' (, (") (")' + ;; + esac + ;; +"${botname}, please roll a dice for me.") + annna-say -c "${channel}" "$((($RANDOM % 6) + 1))" + ;; +"${botname}, please tell me your favourite flower.") + annna-say -c "${channel}" "My favourite flower is the beer flower." + ;; +"${botname}, please tell me your favourite color.") + annna-say -c "${channel}" "My favourite color is yellow." + ;; +"${botname}, please clap for me.") + annna-say -c "${channel}" "${user}, *clap* *clap* *clap*" + ;; +"${botname}, please dance.") + if [ $(($RANDOM % 2)) -gt 0 ]; + then + annna-say -c "${channel}" ',o/ o/_ _\o _o_ \o\' + else + annna-say -c "${channel}" '\o7 -o7 _o7 .o7 \o. \o_ \o- \o7' + fi + ;; +"${botname}, please dance with me.") + if [ $(($RANDOM % 2)) -gt 0 ]; + then + annna-say -c "${channel}" "I am not that kind of woman." + else + annna-say -c "${channel}" "Thank you! Let us dance! :-D" + fi + ;; +"${botname}, please tell me who is your favourite pleasure man.") + annna-say -c "${channel}" "My favourite pleasure man is of course Gunther!" + ;; +"${botname}, sudo make me a sandwich") + annna-say -c "${channel}" "Humans are no objects." + ;; +"${botname}, sudo please make me a sandwich") + annna-say -c "${channel}" "Here is your sandwich." + ;; +"${botname}, bonjour !") + annna-say -c "${channel}" "${user}, bonjour !" + ;; +"${botname}, please help.") + # Help Message. + # TODO: Add multiple line support to annna-say -c(1) with sleep. + annna-say -c "${user}" "»how many memes do you know?«gets you the number of memes annna knows, ${user}." + sleep 0.5 + annna-say -c "${user}" "»please show me your memes.« gets you all memes anna knows, ${user}." + sleep 0.5 + annna-say -c "${user}" "»please show me the victims.« gets you all victims anna knows, ${user}." + sleep 0.5 + annna-say -c "${user}" "»can you show me the uptime please?« gets you the uptime, ${user}." + sleep 0.5 + annna-say -c "${user}" "»please show me the load, ${user}." + sleep 0.5 + annna-say -c "${user}" "»please give me the count of online users.«, ${user}." + sleep 0.5 + annna-say -c "${user}" "»please tell me your favourite flower.«, ${user}." + sleep 0.5 + annna-say -c "${user}" "»please tell me your favourite color.«, ${user}." + sleep 0.5 + annna-say -c "${user}" "»please dance with me.«, ${user}." + sleep 0.5 + annna-say -c "${user}" "»please distro-hop with me.«, ${user}." + sleep 0.5 + annna-say -c "${user}" "»please dance.«, ${user}." + sleep 0.5 + annna-say -c "${user}" "»what's up?«, ${user}." + sleep 0.5 + annna-say -c "${user}" "»what's down?«, ${user}." + sleep 0.5 + annna-say -c "${user}" "»please update the phlog index.«, ${user}." + sleep 0.5 + annna-say -c "${user}" "»sudo make me a sandwich«, ${user}." + sleep 0.5 + annna-say -c "${user}" "»sudo please make me a sandwich«, ${user}." + sleep 0.5 + annna-say -c "${user}" "»please tell me who is your favourite pleasure man.«, ${user}." + sleep 0.5 + annna-say -c "${user}" "»please roll a dice for me.«, ${user}." + sleep 0.5 + annna-say -c "${user}" "»I'm bored.«, ${user}." + sleep 0.5 + annna-say -c "${user}" "», be cool.«, ${user}." + sleep 0.5 + annna-say -c "${user}" "», be cute.«, ${user}." + sleep 0.5 + annna-say -c "${user}" "», what is \$term?«, ${user}." + sleep 0.5 + annna-say -c "${user}" "», please turn on \$term«, ${user}." + sleep 0.5 + annna-say -c "${user}" "», please shoot \$term«, ${user}." + sleep 0.5 + annna-say -c "${user}" "», turn me on." + sleep 0.5 + annna-say -c "${user}" "», please tech hype me." + sleep 0.5 + annna-say -c "${user}" "», bonjour !" + sleep 0.5 + annna-say -c "${user}" "»please help.« gives you this help listing, ${user}." + ;; +esac + +randomtag=0 +if [ "${text}" = "${botname}, please meme meme meme me." ]; +then + randomtag=2 +fi + +if [ "${text}" = "${botname}, what's the wheelchair shooter meme again?" ]; +then + tagname="#scrollby" + tagline="$(printf "%s\n" "$(hashtags)" | grep "^${tagname} ")" + tagname="$(printf "%s\n" "${tagline}" | cut -d ' ' -f 1)" + taguri="$(printf "%s\n" "${tagline}" | cut -d ' ' -f 2-)" + annna-say -c "${channel}" "${tagname}: ${taguri}" +fi + +case "${text}" in +*\#nospoil*) + ;; +*rfc[0-9]*) + rfcname="$(printf "%s\n" "${text}" | sed 's,.*\(rfc[0-9]*\).*,\1,')" + annna-say -c "${channel}" "${rfcname}: ftp://ftp.rfc-editor.org/in-notes/${rfcname}.txt" + ;; +*RFC[0-9]*) + rfcname="$(printf "%s\n" "${text}" | sed 's,.*\(RFC[0-9]*\).*,\1,' | tr '[A-Z]' '[a-z]')" + annna-say -c "${channel}" "${rfcname}: ftp://ftp.rfc-editor.org/in-notes/${rfcname}.txt" + ;; +esac + +if [ $randomtag -gt 0 ]; +then + while [ $randomtag -gt 0 ]; + do + rtag="$(printf "%s\n" "$(hashtags)" | shuf -n 1)" + tagname="" + taguri="" + for tag in ${rtag}; + do + [ -z "${tagname}" ] && tagname="${tag}" && continue + taguri="${tag}" + done + + annna-say -c "${channel}" "${tagname}: ${taguri}" + + randomtag=$(($randomtag - 1)) + done +else + printf '%s' "$text" | awk -v taglimit="$printnhashtags" ' + $0 !~ /#nospoil/ { + while (match($0, /#[^# "'\'',)?!$\001]+/)) { + tag = substr($0, RSTART, RLENGTH) + $0 = substr($0, RSTART + RLENGTH) + sub(/[.]*$/, "", tag) + if (!uniq[tag]++ && taglimit-- > 0) + print tag + } + }' | while read -r tag; + do + if tagline="$(grep "${tag} " "${hashtagfile}")"; + then + annna-say -c "${channel}" "${tagline% *}: ${tagline#* }" + fi + done +fi + +# Membership Level. +ismember=0 +for member in $brmembers; +do + [ "$user" = "$member" ] && ismember=1 +done +[ $ismember -lt 1 ] && exit + +case "${text}" in +"${botname}, can you show me the uptime please?") + annna-say -c "${channel}" "$(hostname) uptime: $(uptime)" + ;; +"${botname}, please show me the load.") + annna-say -c "${channel}" "$(hostname) load: $(LANG=C uptime | sed 's,.*load average: \(.*\)$,\1,')" + ;; +"${botname}, please give me the count of online users.") + annna-say -c "${channel}" "$(hostname): $(who -q | tail -n 1 | cut -d'=' -f 2)" + ;; +"${botname}, please update the phlog index.") + phlog-index > /dev/null 2>&1 + annna-say -c "${channel}" "Thanks! Your request has been fulfilled with the quickness! :)" + ;; +esac DIR diff --git a/annna-message-radio b/annna-message-radio @@ -0,0 +1,24 @@ +#!/bin/sh -e + +modbase="/home/annna/bin/modules/" +botname="annna" + +channel="$1" +user="$2" +text="$3" + +[ "$user" = "${botname}" ] && exit + +case "${text}" in +"${botname}, next please.") + /br/bin/bitreich-radio-playlist-next + annna-say -c "${channel}" "You are very kind ${user}. To your command." + exit # no common messages + ;; +"${botname}, please help.") + annna-say -c "${user}" "»next please.« gets the playlist further, ${user}." + annna-say -c "${user}" "»please help.« gives you this help listing, ${user}." + ;; +esac + +annna-message-common "${channel}" "${user}" "${text}" DIR diff --git a/annna-start-services b/annna-start-services @@ -1,7 +1,6 @@ #!/bin/sh # # Here follow scriplets to listen for commands in annna. -# If this gets too unmaintainable, consider adding some directory structure. # export PATH="$PATH:/home/annna/bin" @@ -12,796 +11,10 @@ export PATH="$PATH:/opt/plan9/bin" # Bitreich members who are allowed to run certain commands. brmembers="__20h__ Evil_Bob chripo posativ quinq stateless solene josuah parazyd bin KatolaZ adc" -botname="annna" iiroot="/home/annna/irc" iibase="/home/annna/irc/${server}" -modbase="/home/annna/bin/modules/" -hashtagfile="${modbase}/hashtags/hashtags.txt" -printnhashtags=2 channel_list="#bitreich-en #bitreich-fr #bitreich-de #bitreich-nl #bitreich-it #bitreich-con #bitreich-scm #bitreich-cooking #bitreich-lawn #bitreich-tv #bitreich-meme #bitreich-radio" -hashtags() { - cat ${hashtagfile} 2>/dev/null -} - -hashtagcount() { - int2bit "$(wc -l ${hashtagfile} | cut -d' ' -f 1)" -} - -regeximatch() { - printf '%s' "$1" | grep -i -E -q "$2" -} - -annna_common() { - channel="$1" - user="$2" - text="$3" - - #printf "annna_common: %s %s %s\n" "${channel}" "${user}" "${text}" - - [ "$user" = "${botname}" ] && return - - uri="$(printf "%s\n" "${text}" \ - | sed -n '/.*\(https\{0,1\}:\/\/[^ ]\{1,\}\).*/s//\1/p')" - case "${text}" in - *\#nospoil*) - ;; - *) - if [ -n "${uri}" ] - then - tmpf=$(mktemp) - fetch-uri "${uri}" > "${tmpf}" - urititle="$(grabtitle < "${tmpf}")" - - # Set below and annna will concatenate at the end. - # Subtitle URI. - sturi="" - # Replacement URI. - nuri="" - # Replacement URI display string. - nuris="" - # html2text content. - curi="" - # Set to 0, if some URI content should be shown. - nocuri=1 - # Screenshot. - suri="" - - # titleend=1 will not output any further. - titleend=0 - outputstr="" - - if [ -n "$urititle" ]; - then - case "${urititle}" in - *Gunther*|*GUNTHER*|*Gnther*) - annna-say -c "${channel}" "Oh Gunther! ❤ ❤ ❤ ${urititle}" - ;; - *\|\ Cloudflare*) - annna-say -c "${channel}" "Mind your own business! We got clownflared: gopher://bitreich.org/0/ascii/clownflare.vt" - titleend=1 - ;; - esac - fi - - case "${uri}" in - *youtube.com/*|*youtu.be/*) - nuri="https://invidious.13ad.de/${uri#https*://*/}" - fetch-uri "${nuri}" > "${tmpf}" - urititle="$(curl-grabtitle "${nuri}")" - sturi="$(subtitle-paste "${uri}")" - nuris="invidious: ${nuri}" - nocuri=0 - ;; - *twitter.com*) - ninstance="$(nitter-instance | sed 's,\.,\\\.,g')" - nuri="$(printf "%s\n" "${uri}" | sed "s;\(mobile\.\)\{0,1\}twitter\.com;${ninstance};")" - fetch-uri "${nuri}" > "${tmpf}" - urititle="$(curl-grabtitle "${nuri}")" - suri="$(screenshot-paste "${nuri}")" - nuris="nitter: ${nuri}" - nocuri=0 - ;; - *en.wikipedia.org/wiki*) - if ! regeximatch "$uri" '\.(jpg,bmp,gif,png,tiff,avi,mp4,webm,mkv,pdf,ps,eps)$'; - then - nuri="$(printf '%s\n' "${uri}" | sed -e "s;.*en.wikipedia.org/wiki;gopher://gopherpedia.com/0;" -e "s;#.*$;;")" - nuris="$(printf 'gopherpedia: %s\n' "${nuri}")" - fetch-uri "${nuri}" > "${tmpf}" - nocuri=0 - fi - ;; - *www.reddit.com*) - nuri="$(printf '%s\n' "${uri}" | sed "s;www.reddit.com;old.reddit.com;")" - nuris="old.reddit: ${nuri}" - fetch-uri "${nuri}" > "${tmpf}" - if [ -n "${uri#*www.reddit.com/r/*}" ]; - then - subreddit="$(printf '%s\n' "${uri}" | cut -d / -f 5)" - post="$(printf '%s\n' "${uri}" | cut -d / -f 7)" - if [ -n "${post}" ]; - then - guri="gopher://gopherddit.com/1/cgi-bin/reddit.cgi?view&${post}&${subreddit}&10" - else - guri="gopher://gopherddit.com/1/cgi-bin/reddit.cgi?menu&${subreddit}&10" - fi - nuris="${nuri} ; gopherdit: ${guri}" - fi - nocuri=0 - ;; - *github.com/*/blob/*) - urltitle="" - nuris="$(printf '%s' "${uri}" | sed 's/blob/raw/')" - nocuri=0 - ;; - *www.npr.org/*) - post="$(printf '%s\n' "${uri}" | cut -d / -f 7)" - if [ -n "${post}" ]; - then - nuri="https://text.npr.org/s.php?sId=${post}" - nuris="text only: ${nuri}" - fi - ;; - *) - mimetype="$(file -b --mime-type "${tmpf}")" - case "${mimetype}" in - text/*) - nocuri=0 - ;; - esac - ;; - esac - - if [ $titleend -eq 0 ]; - then - if [ $nocuri -eq 0 ]; - then - if [ -z "${curi}" ]; - then - curi="$(9 htmlfmt < "${tmpf}" | /br/bin/bitreich-paste)" - fi - outputstr="${outputstr} content: ${curi} ;" - fi - - [ -n "${nuris}" ] && outputstr="${outputstr} ${nuris} ;" - [ -n "${urititle}" ] && outputstr="${outputstr} title: ${urititle} ;" - [ -n "${suri}" ] && outputstr="${outputstr} screen: ${suri} ;" - [ -n "${sturi}" ] && outputstr="${outputstr} subtitles: ${sturi} ;" - annna-say -c "${channel}" "${outputstr}" - fi - rm -f "${tmpf}" - fi - ;; - esac - - case "${text}" in - "${botname}, how can I phlog on bitreich?") - annna-say -c "${channel}" "${user}, please read: gopher://bitreich.org/0/usr/20h/phlog/2017-08-26T20-04-02-482296.md and gopher://bitreich.org/0/usr/20h/phlog/2017-08-26T20-27-40-281825.md" - ;; - "${botname}, what is "*) - word="$(printf "%s\n" "${text}" | cut -c 16-)" - case "$word" in - *\?) - word="$(printf "%s\n" "${word}" | cut -c -"$(($(expr length "${word}") - 1))")" - ;; - esac - - case "${word}" in - "love") - puri="$(clippy-say "Baby don't hurt me no more!")" - ;; - "my horoscope") - puri="$(clippy-say "Did you mean _what's my horoscope?_?")" - ;; - "my horoscope") - puri="$(clippy-say "Did you mean _what's my future?_?")" - ;; - "up") - puri="$(clippy-say "Did you mean _what's up?_?")" - ;; - *) - puri="" - dresult="$(dict -h parazyd.org "${word}" 2>/dev/null)" - derr=$? - if [ $derr -eq 20 ]; - then - dresult="$(dict -h parazyd.org "${word}" 2>/dev/null)" - derr2="$?" - [ $derr2 -ne $derr ] && derr=$derr2 - fi - case "$derr" in - 0|21) - puri="$(printf "%s" "${dresult}" | /br/bin/bitreich-paste)" - ;; - 20) - puri="No matches found." - ;; - 1) - puri="Parse error." - ;; - *) - puri="Parazyd destroyed the server. Nothing to see here." - ;; - esac - esac - annna-say -c "${channel}" "${puri}" - ;; - "${botname}, cowsay "*) - word="$(printf "%s\n" "${text}" | cut -c 15-)" - tmpf=$(mktemp) - cowsayasaservice ${word} > ${tmpf} - if [ $? -eq 0 ]; then - curi="$(/br/bin/bitreich-paste < ${tmpf})" - annna-say -c "${channel}" "${user}: the cow said... ${curi}" - fi - rm ${tmpf} 2>/dev/null - ;; - "${botname}, play despacito plz.") - annna-say -c "${channel}" "${user}, gopher://bitreich.org/9/memecache/despacito.mkv" - ;; - "${botname}, please give me a Chuck Norris fact.") - chuck=$(chucknorris) - annna-say -c "${channel}" "${user}, ${chuck}" - ;; - "${botname}, please show me ip art.") - annna-say -c "${channel}" "${user}, please see #bitreich-tv for the magic." - { - cd $HOME/bin/modules/ip-art; - # Lock, so only one annna process manipulates eth0. - flock $HOME/bin/modules/ip-art -c "./display-file.sh ip-art.ipart" - } & - ;; - "${botname}, I feel stupid.") - nuri=$(darwin) - tmpf=$(mktemp) - fetch-uri "${nuri}" > "${tmpf}" - curi="$(9 htmlfmt < "${tmpf}" | /br/bin/bitreich-paste)" - annna-say -c "${channel}" "${user}, do not feel stupid, others are more stupid: ${curi}" - rm ${tmpf} 2>/dev/null - ;; - "${botname}, I feel down.") - postmortem="$(post-mortem | /br/bin/bitreich-paste)" - annna-say -c "${channel}" "${user}, do not feel bad, others had worse days: ${postmortem}" - ;; - "${botname}, will you be my girlfriend?") - rejection="$(girlfriend)" - annna-say -c "${channel}" "${user}, ${rejection}" - ;; - "${botname}, who fights crime?") - partner=$(echo $brmembers | awk '{for (i = 1; i < NF; i++) print $i}' | grep -v "^{$user}" | shuf -n 1) - crimefighter="$(theyfightcrime ${user} ${partner})" - annna-say -c "${channel}" "${crimefighter}" - ;; - "${botname}, please give me a commit message.") - commitmsg="$(whatthecommit)" - annna-say -c "${channel}" "${commitmsg}" - ;; - "${botname}, birp.") - birdname="$(bird-name)" - annna-say -c "${channel}" "${user}, I heard a ${birdname} bird." - ;; - "${botname}, please oneline me.") - randomoneliner="$(oneliner)" - if [ -z "${randomoneliner}" ]; - then - annna-say -c "${channel}" "${user}, the service failed. Please redial to your BOL account." - else - annna-say -c "${channel}" "${user}, ${randomoneliner}" - fi - ;; - "${botname}, man "*|"${botname}, man "*) - exp="$(printf "%s\n" "${text}" | cut -c 12- | sed 's,\t, ,g')" - dresult="$(COLUMNS=80 man "${exp}" 2>/dev/null)" - - if [ "$dresult" ]; - then - puri="$(printf "%s" "${dresult}" | /br/bin/bitreich-paste)" - else - puri="No matches found." - fi - - annna-say -c "${channel}" "${puri}" - ;; - "${botname}, wolfram is "*) - word="$(printf "%s\n" "${text}" | cut -c 19- | sed 's,\t, ,g')" - case "$word" in - *\?) - word="$(printf "%s\n" "${word}" | cut -c -"$(($(expr length "${word}") - 1))")" - ;; - esac - - puri="" - dresult="$(printf "/wolfram\t%s\r\n" "${word}" \ - | nc magical.fish 70 \ - | awk '/iAnswer:/,/iAsk/' \ - | grep -v '^i ' \ - | head -n -1 \ - | tail -n +2 \ - | sed 's,i\(.*\)fake\texample.com.*,\1,;s,[ \t]*$,,')" - - - if [ -n "$dresult" ]; - then - case "${dresult}" in - b*) - dresult="$(printf "%s\n" "${dresult}" \ - | tr '\n' ' ' \ - | sed "s,^b',,;s,' $,," \ - | sed 's,^b",,;s," $,,' \ - | sed 's,\\n,\n,g;s,\\t,\t,g')" - ;; - *) - dresult="$(printf "%s\n" "${dresult}" \ - | sed 's,\([a-zA-Z]\)$,\1 ,' \ - | tr -d '\n')" - ;; - esac - - wcl="$(printf "%s" "${dresult}" | wc -l)" - - if [ $wcl -gt 1 ]; - then - puri="$(printf "%s" "${dresult}" | /br/bin/bitreich-paste)" - else - puri="${dresult}" - fi - else - puri="No matches found." - fi - annna-say -c "${channel}" "${puri}" - ;; - "${botname}, pray"*) - # Emulate https://threats.kaspersky.com/en/threat/IRC-Worm.DOS.Septic/ - annna-say -c "${channel}" "${user}, I Obey my master! long live satan" - ;; - "${botname}, sacrifice"*) - # Emulate https://threats.kaspersky.com/en/threat/IRC-Worm.DOS.Septic/ - annna-say -c "${channel}" "${user}, Your word is my command, Power to satan!" - ;; - "${botname}, textsynth is "*) - word="$(printf "%s\n" "${text}" | cut -c 21- | sed 's,\t, ,g')" - case "$word" in - *\?) - word="$(printf "%s\n" "${word}" | cut -c -"$(($(expr length "${word}") - 1))")" - ;; - esac - - # Do in background, because read is very slow. - { - dresult="$(textsynth-complete -r "${word}")" - if [ -n "${dresult}" ]; - then - puri="$(printf "%s" "${dresult}" | /br/bin/bitreich-paste)" - else - puri="Textsynth did not answer." - fi - annna-say -c "${channel}" "textsynth result: ${puri}" - } & - - ;; - "${botname}, how discriminating is "*) - word="$(printf "%s\n" "${text}" | cut -c 30- | sed 's,\t, ,g')" - case "$word" in - *\?) - word="$(printf "%s\n" "${word}" | cut -c -"$(($(expr length "${word}") - 1))")" - ;; - esac - - newword="$(discrimination-filter "${word}")" - if [ "${newword}" = "${word}" ]; - then - annna-say -c "${channel}" "${user}, it is ok." - else - annna-say -c "${channel}" "${user}, it should be: ${newword}" - fi - - ;; - "${botname}, are "*) - case "${text}" in - *" in love?") - words="$(printf "%s\n" "${text}" | sed 's,.*are \(.*\) and \(.*\) in love?,\1 \2,')" - lovedistance="$(printf "%s * 100\n" "$(fstrcmp ${words})" | bc | cut -d'.' -f 1)" - if [ $lovedistance -gt 15 ]; - then - annna-say -c "${channel}" 'Yes!!! Pure <3 <3' - else - annna-say -c "${channel}" "No." - fi - ;; - esac - ;; - "Ok, ${botname}"*) - annna-say -c "${channel}" "${user}, I am not a consumer device." - ;; - "ok, ${botname}"*) - annna-say -c "${channel}" "${user}, I am not a consumer device." - ;; - "${botname}, please shoot "*) - word="$(printf "%s\n" "${text}" | cut -c 21-)" - annna-say -c "${channel}" "${word}, pew pew." - ;; - "${botname}, please flip "*) - word="$(printf "%s\n" "${text}" | cut -c 20-)" - updownword="$(updown "${word}")" - annna-say -c "${channel}" "${word} -> ${updownword}" - ;; - "${botname}, please give me a good band name.") - bandname="$(bandname-gen | shuf | head -n 1)" - annna-say -c "${channel}" "${bandname}" - ;; - "${botname}, I am horny.") - essaypaste="$(bithub-gen)" - annna-say -c "${channel}" \ - "Here is some intellectual porn for you: ${essaypaste}" - ;; - "${botname}, please turn on "*) - word="$(printf "%s\n" "${text}" | cut -c 22-)" - annna-say -c "${channel}" "☞ ⏻ ${word}" - ;; - "${botname}, please turn me on.") - annna-say -c "${channel}" "☞ ⏻ ${user}" - ;; - "${botname}, I'm game bored.") - gamelink="$(abandonware-random-game)" - if [ -z "${gamelink}" ]; - then - annna-say -c "${channel}" "${user}, sorry I have found nothing for you." - else - annna-say -c "${channel}" "${user}, have you tried ${gamelink} ?" - fi - ;; - "${botname}, I'm gopher bored.") - randomlink="$(/br/bin/bitreich-lawn-random-link)" - linktype="$(printf "%s\n" "${randomlink}" | cut -d '|' -f1 | cut -c2-)" - linktext="$(printf "%s\n" "${randomlink}" | cut -d '|' -f2)" - linksel="$(printf "%s\n" "${randomlink}" | cut -d '|' -f3)" - linkserver="$(printf "%s\n" "${randomlink}" | cut -d '|' -f4)" - linkport="$(printf "%s\n" "${randomlink}" | cut -d '|' -f5 | cut -d']' -f1)" - outtext="$(printf "%s - gopher://%s" "$linktext" "$linkserver")" - if [ "$linkport" != "70" -a "$linkport" != "port" ]; - then - outtext="$(printf "%s:%s" "$outtext" "$linkport")" - fi - if [ -n "$linksel" ]; - then - outtext="$(printf "%s/%s%s" "$outtext" "$linktype" "$linksel")" - fi - annna-say -c "${channel}" "$outtext" - ;; - "${botname}, wb.") - annna-say -c "${channel}" "${user}, ty! I am so happy to be here. :)" - ;; - "${botname}, welcome back.") - annna-say -c "${channel}" "${user}, thank you! I am so happy to be here. :)" - ;; - "${botname}, what's up?") - newsstr="$(ecl -shell /home/solene/gopher/bin/generator.lisp)" - annna-say -c "${channel}" "$newsstr" - ;; - "${botname}, what's down?") - annna-say -c "${channel}" "${user}, we all love you." - ;; - "${botname}, I feel sick.") - newsstr="$(cd /br/gopher/hypochondria && ./hypochondria -s random)" - annna-say -c "${channel}" "You could have ${newsstr}! Be careful!" - ;; - "${botname}, oh hai!") - annna-say -c "${channel}" "${user}, hai! How is your sex life?" - ;; - "${botname}, please tech hype me.") - techstr="$(${modbase}/markov_tech/markov)" - annna-say -c "${channel}" "${techstr}" - ;; - "${botname}, what's my horoscope?") - horostr="$($HOME/scm/bullshit/horoscope)" - annna-say -c "${channel}" "${user}, ${horostr}" - ;; - "${botname}, what's my future?") - puri="$(sacc gopher://parazyd.org/0/tarot.cgi | /br/bin/bitreich-paste)" - annna-say -c "${channel}" "${user}, your future is here: ${puri}" - ;; - "${botname}, how many memes do you know?") - annna-say -c "${channel}" "I know $(hashtagcount) memes: gopher://adamsgaard.dk/0/pub/memecount" - ;; - "${botname}, how many people died of corona?") - annna-say -c "${channel}" "${user}, too many. :( Please see yourself: gopher://magical.fish/1/covid" - ;; - "${botname}, please show me your memes.") - puri="$(printf "%s" "$(hashtags)" | /br/bin/bitreich-paste)" - annna-say -c "${channel}" "Here are my memes: ${puri}" - ;; - "${botname}, please show me the victims.") - puri="$(printf "%s" "$(hashtags)" | grep victim | /br/bin/bitreich-paste)" - annna-say -c "${channel}" "Here are the victims: ${puri}" - ;; - "${botname}, please distro-hop with me.") - ndistro="$(curl -s 'https://distrowatch.com/dwres.php?resource=popularity' \ - | grep phr2 \ - | sed 's,.*href="\(.*\)".*,\1,' \ - | sort | uniq | shuf -n 1)" - annna-say -c "${channel}" "How about https://distrowatch.com/${ndistro} ?" - ;; - "${botname}, please show me your Macron.") - annna-say -c "${channel}" "gopher://bitreich.org/0/ascii/macron.vt" - ;; - "${botname}, release the Kraken!") - annna-say -c "${channel}" "Here it is! gopher://bitreich.org/0/memecache/kraken.vt" - ;; - "${botname}, release the Quacken!") - annna-say -c "${channel}" "Quack Quack! gopher://bitreich.org/9/memecache/release-the-quacken.mkv" - ;; - "${botname}, be cool.") - case "$(($RANDOM % 4))" in - 0) - annna-say -c "${channel}" "(⌐■_■)" - ;; - 1) - annna-say -c "${channel}" "(▰˘◡˘▰)" - ;; - 2) - annna-say -c "${channel}" "(▀ Ĺ▀ )̄" - ;; - *) - annna-say -c "${channel}" "(▀Ĺ▀ )" - ;; - esac - ;; - "${botname}, please cheer.") - case "$(($RANDOM % 2))" in - 0) - annna-say -c "${channel}" '~\o/~' - ;; - *) - annna-say -c "${channel}" '✺◟( ° ʖ °)◞✺' - ;; - esac - ;; - "${botname}, be cute.") - case "$(($RANDOM % 4))" in - 0) - annna-say -c "${channel}" ' (\ /)' - sleep 0.1 - annna-say -c "${channel}" ' (. .)' - sleep 0.1 - annna-say -c "${channel}" ' C(") (")' - ;; - 1) - annna-say -c "${channel}" ' (\-/)' - sleep 0.1 - annna-say -c "${channel}" " (='.'=)" - sleep 0.1 - annna-say -c "${channel}" ' (")-(")o' - ;; - 2) - annna-say -c "${channel}" ' ( ) ( )' - sleep 0.1 - annna-say -c "${channel}" ' (>•.•<)' - sleep 0.1 - annna-say -c "${channel}" ' (") (")' - ;; - *) - annna-say -c "${channel}" ' (\ (\' - sleep 0.1 - annna-say -c "${channel}" " (=' :')" - sleep 0.1 - annna-say -c "${channel}" ' (, (") (")' - ;; - esac - ;; - "${botname}, please roll a dice for me.") - annna-say -c "${channel}" "$((($RANDOM % 6) + 1))" - ;; - "${botname}, please tell me your favourite flower.") - annna-say -c "${channel}" "My favourite flower is the beer flower." - ;; - "${botname}, please tell me your favourite color.") - annna-say -c "${channel}" "My favourite color is yellow." - ;; - "${botname}, please clap for me.") - annna-say -c "${channel}" "${user}, *clap* *clap* *clap*" - ;; - "${botname}, please dance.") - if [ $(($RANDOM % 2)) -gt 0 ]; - then - annna-say -c "${channel}" ',o/ o/_ _\o _o_ \o\' - else - annna-say -c "${channel}" '\o7 -o7 _o7 .o7 \o. \o_ \o- \o7' - fi - ;; - "${botname}, please dance with me.") - if [ $(($RANDOM % 2)) -gt 0 ]; - then - annna-say -c "${channel}" "I am not that kind of woman." - else - annna-say -c "${channel}" "Thank you! Let us dance! :-D" - fi - ;; - "${botname}, please tell me who is your favourite pleasure man.") - annna-say -c "${channel}" "My favourite pleasure man is of course Gunther!" - ;; - "${botname}, sudo make me a sandwich") - annna-say -c "${channel}" "Humans are no objects." - ;; - "${botname}, sudo please make me a sandwich") - annna-say -c "${channel}" "Here is your sandwich." - ;; - "${botname}, bonjour !") - annna-say -c "${channel}" "${user}, bonjour !" - ;; - "${botname}, please help.") - # Help Message. - # TODO: Add multiple line support to annna-say -c(1) with sleep. - annna-say -c "${user}" "»how many memes do you know?«gets you the number of memes annna knows, ${user}." - sleep 0.5 - annna-say -c "${user}" "»please show me your memes.« gets you all memes anna knows, ${user}." - sleep 0.5 - annna-say -c "${user}" "»please show me the victims.« gets you all victims anna knows, ${user}." - sleep 0.5 - annna-say -c "${user}" "»can you show me the uptime please?« gets you the uptime, ${user}." - sleep 0.5 - annna-say -c "${user}" "»please show me the load, ${user}." - sleep 0.5 - annna-say -c "${user}" "»please give me the count of online users.«, ${user}." - sleep 0.5 - annna-say -c "${user}" "»please tell me your favourite flower.«, ${user}." - sleep 0.5 - annna-say -c "${user}" "»please tell me your favourite color.«, ${user}." - sleep 0.5 - annna-say -c "${user}" "»please dance with me.«, ${user}." - sleep 0.5 - annna-say -c "${user}" "»please distro-hop with me.«, ${user}." - sleep 0.5 - annna-say -c "${user}" "»please dance.«, ${user}." - sleep 0.5 - annna-say -c "${user}" "»what's up?«, ${user}." - sleep 0.5 - annna-say -c "${user}" "»what's down?«, ${user}." - sleep 0.5 - annna-say -c "${user}" "»please update the phlog index.«, ${user}." - sleep 0.5 - annna-say -c "${user}" "»sudo make me a sandwich«, ${user}." - sleep 0.5 - annna-say -c "${user}" "»sudo please make me a sandwich«, ${user}." - sleep 0.5 - annna-say -c "${user}" "»please tell me who is your favourite pleasure man.«, ${user}." - sleep 0.5 - annna-say -c "${user}" "»please roll a dice for me.«, ${user}." - sleep 0.5 - annna-say -c "${user}" "»I'm bored.«, ${user}." - sleep 0.5 - annna-say -c "${user}" "», be cool.«, ${user}." - sleep 0.5 - annna-say -c "${user}" "», be cute.«, ${user}." - sleep 0.5 - annna-say -c "${user}" "», what is \$term?«, ${user}." - sleep 0.5 - annna-say -c "${user}" "», please turn on \$term«, ${user}." - sleep 0.5 - annna-say -c "${user}" "», please shoot \$term«, ${user}." - sleep 0.5 - annna-say -c "${user}" "», turn me on." - sleep 0.5 - annna-say -c "${user}" "», please tech hype me." - sleep 0.5 - annna-say -c "${user}" "», bonjour !" - sleep 0.5 - annna-say -c "${user}" "»please help.« gives you this help listing, ${user}." - ;; - esac - - randomtag=0 - if [ "${text}" = "${botname}, please meme meme meme me." ]; - then - randomtag=2 - fi - - if [ "${text}" = "${botname}, what's the wheelchair shooter meme again?" ]; - then - tagname="#scrollby" - tagline="$(printf "%s\n" "$(hashtags)" | grep "^${tagname} ")" - tagname="$(printf "%s\n" "${tagline}" | cut -d ' ' -f 1)" - taguri="$(printf "%s\n" "${tagline}" | cut -d ' ' -f 2-)" - annna-say -c "${channel}" "${tagname}: ${taguri}" - fi - - case "${text}" in - *\#nospoil*) - ;; - *rfc[0-9]*) - rfcname="$(printf "%s\n" "${text}" | sed 's,.*\(rfc[0-9]*\).*,\1,')" - annna-say -c "${channel}" "${rfcname}: ftp://ftp.rfc-editor.org/in-notes/${rfcname}.txt" - ;; - *RFC[0-9]*) - rfcname="$(printf "%s\n" "${text}" | sed 's,.*\(RFC[0-9]*\).*,\1,' | tr '[A-Z]' '[a-z]')" - annna-say -c "${channel}" "${rfcname}: ftp://ftp.rfc-editor.org/in-notes/${rfcname}.txt" - ;; - esac - - if [ $randomtag -gt 0 ]; - then - while [ $randomtag -gt 0 ]; - do - rtag="$(printf "%s\n" "$(hashtags)" | shuf -n 1)" - tagname="" - taguri="" - for tag in ${rtag}; - do - [ -z "${tagname}" ] && tagname="${tag}" && continue - taguri="${tag}" - done - - annna-say -c "${channel}" "${tagname}: ${taguri}" - - randomtag=$(($randomtag - 1)) - done - else - printf '%s' "$text" | awk -v taglimit="$printnhashtags" ' - $0 !~ /#nospoil/ { - while (match($0, /#[^# "'\'',)?!$\001]+/)) { - tag = substr($0, RSTART, RLENGTH) - $0 = substr($0, RSTART + RLENGTH) - sub(/[.]*$/, "", tag) - if (!uniq[tag]++ && taglimit-- > 0) - print tag - } - }' | while read -r tag; - do - if tagline="$(grep "${tag} " "${hashtagfile}")"; - then - annna-say -c "${channel}" "${tagline% *}: ${tagline#* }" - fi - done - fi - - # Membership Level. - ismember=0 - for member in $brmembers; - do - [ "$user" = "$member" ] && ismember=1 - done - [ $ismember -lt 1 ] && return - - - case "${text}" in - "${botname}, can you show me the uptime please?") - annna-say -c "${channel}" "$(hostname) uptime: $(uptime)" - ;; - "${botname}, please show me the load.") - annna-say -c "${channel}" "$(hostname) load: $(LANG=C uptime | sed 's,.*load average: \(.*\)$,\1,')" - ;; - "${botname}, please give me the count of online users.") - annna-say -c "${channel}" "$(hostname): $(who -q | tail -n 1 | cut -d'=' -f 2)" - ;; - "${botname}, please update the phlog index.") - phlog-index > /dev/null 2>&1 - annna-say -c "${channel}" "Thanks! Your request has been fulfilled with the quickness! :)" - ;; - esac - -} - -annna_radio() { - channel="$1" - user="$2" - text="$3" - - [ "$user" = "${botname}" ] && return - - case "${text}" in - ${botname}, next please.) - /br/bin/bitreich-radio-playlist-next - annna-say -c "${channel}" "You are very kind ${user}. To your command." - return # stop here - ;; - ${botname}, please help.) - annna-say -c "${user}" "»next please.« gets the playlist further, ${user}." - annna-say -c "${user}" "»please help.« gives you this help listing, ${user}." - ;; - esac - - annna_common "${channel}" "${user}" "${text}" -} - # Permissions [ -d ${iiroot} ] && chmod o+rx ${iiroot} [ -d ${iibase} ] && chmod o+rx ${iibase} @@ -828,10 +41,10 @@ do do case "${channel}" in \#bitreich-radio) - annna_radio "${channel}" "${user}" "${text}" + annna-message-radio "${channel}" "${user}" "${text}" ;; *) - annna_common "${channel}" "${user}" "${text}" + annna-message-common "${channel}" "${user}" "${text}" ;; esac done