| Reduce sloc with more personality logic and bash shortcuts. - annna - Annna the… | |
| git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6… | |
| Log | |
| Files | |
| Refs | |
| Tags | |
| README | |
| --- | |
| commit 0117f54a4a5e061cd6b524514f65b7eb325ebfc1 | |
| parent ae39f7d89e846846281873d6aaaec0c071b1f956 | |
| Author: Annna Robert-Houdin <[email protected]> | |
| Date: Sun, 19 Oct 2025 11:37:26 +0200 | |
| Reduce sloc with more personality logic and bash shortcuts. | |
| Thanks seninha for all of your work! | |
| Diffstat: | |
| M annna-message-common | 298 ++++++++++++-----------------… | |
| 1 file changed, 118 insertions(+), 180 deletions(-) | |
| --- | |
| diff --git a/annna-message-common b/annna-message-common | |
| @@ -24,6 +24,24 @@ dospoil=0 | |
| # Expand meme hashtag and show recommendations. | |
| doexpand=0 | |
| +# Personalities. | |
| +declare -A personalities | |
| +add_personality() { | |
| + printf "@ = %s\n" "$@" >&2 | |
| + for personality in "$@"; | |
| + do | |
| + personalities+=(["${personality}"]="$1") | |
| + done | |
| +} | |
| +for person in preacher uplift trump mao teleromeo modem orphet luther sadh_gur… | |
| +do | |
| + add_personality "${person}" | |
| +done | |
| +add_personality grumpy-fart grumpy | |
| +add_personality santa sannnta | |
| +add_personality satan satannn | |
| +add_personality sigmund-freud freud sigmund | |
| + | |
| regeximatch() { | |
| printf '%s' "$1" | grep -i -E -q "$2" | |
| } | |
| @@ -588,102 +606,10 @@ case "${IRC_PRIVMSG_TEXT}" in | |
| fi | |
| fi;; | |
| "${IRC_USER}, gpt "*) | |
| - # TODO: use modules/prompt-agents | |
| prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 12- | sed 's,\t… | |
| { | |
| annna-say "$(gpt "${prompt}. Please answer short and precise."… | |
| } & ;; | |
| -"Preacher, "*|"preacher, "*) | |
| - personality="preacher" | |
| - preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.… | |
| - prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 2- | sed … | |
| - { | |
| - annna-say "$(gpt "System: ${preprompt}\n User: ${prompt}\n Bot… | |
| - } & ;; | |
| -"Uplift, "*|"uplift, "*) | |
| - personality="uplifting" | |
| - preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.… | |
| - prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 2- | sed … | |
| - { | |
| - annna-say "$(gpt "System: ${preprompt}\n User: ${prompt}\n Bot… | |
| - } & ;; | |
| -"Grumpy, "*|"grumpy, "*) | |
| - personality="grumpy-fart" | |
| - preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.… | |
| - prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 2- | sed … | |
| - { | |
| - annna-say "$(gpt "System: ${preprompt}\n User:${prompt}\n Bot:… | |
| - } & ;; | |
| -"Santa, "*|"Sannnta, "*|"santa, "*|"sannnta, "*) | |
| - personality="santa" | |
| - preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.… | |
| - prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 2- | sed … | |
| - { | |
| - annna-say "$(gpt "System: ${preprompt}\n User: ${prompt}\n Bot… | |
| - } & ;; | |
| -"Satan, "*|"Satannn, "*|"satan, "*|"satannn, "*) | |
| - personality="satan" | |
| - preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.… | |
| - prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 2- | sed … | |
| - { | |
| - annna-say "$(gpt "System: ${preprompt}\n User: ${prompt}\n Bot… | |
| - } & ;; | |
| -"Trump, "*|"trump, "*) | |
| - personality="trump" | |
| - preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.… | |
| - prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 2- | sed … | |
| - { | |
| - annna-say "$(gpt "System: ${preprompt}\n User: ${prompt}\n Bot… | |
| - } & ;; | |
| -"Freud, "*|"freud, "*|"Sigmund, "*|"sigmund, "*) | |
| - personality="sigmund-freud" | |
| - preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.… | |
| - prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 2- | sed … | |
| - { | |
| - annna-say "$(gpt "System: ${preprompt}\n User:${prompt}\n Bot:… | |
| - } & ;; | |
| -"Mao, "*|"mao, "*) | |
| - personality="mao" | |
| - preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.… | |
| - prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 2- | sed … | |
| - { | |
| - annna-say "$(gpt "System: ${preprompt}\n User:${prompt}\n Bot:… | |
| - } & ;; | |
| -"Teleromeo, "*|"teleromeo, "*) | |
| - personality="teleromeo" | |
| - preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.… | |
| - prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 2- | sed … | |
| - { | |
| - annna-say "$(gpt "System: ${preprompt}\n User:${prompt}\n Bot:… | |
| - } & ;; | |
| -"Modem, "*|"modem, "*) | |
| - personality="modem" | |
| - preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.… | |
| - prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 2- | sed … | |
| - { | |
| - annna-say "$(gpt "System: ${preprompt}\n User: ${prompt}\n Bot… | |
| - } & ;; | |
| -"Sadh_Guru, "*|"Sadh_guru, "*|"sadh_guru, "*|"sadh_Guru, "*) | |
| - personality="sadh_guru" | |
| - preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.… | |
| - prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 2- | sed … | |
| - { | |
| - annna-say "$(gpt "System: ${preprompt}\n User: ${prompt}\n Bot… | |
| - } & ;; | |
| -"Prophet, "*|"prophet, "*) | |
| - personality="prophet" | |
| - preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.… | |
| - prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 2- | sed … | |
| - { | |
| - annna-say "$(gpt "System: ${preprompt}\n User: ${prompt}\n Bot… | |
| - } & ;; | |
| -"Luther, "*|"luther, "*) | |
| - personality="luther" | |
| - preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.… | |
| - prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 2- | sed … | |
| - { | |
| - annna-say "$(gpt "System: ${preprompt}\n User: ${prompt}\n Bot… | |
| - } & ;; | |
| "${IRC_USER}, wolfram is "*) | |
| word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 19- | sed 's,\t, … | |
| case "$word" in | |
| @@ -1129,6 +1055,106 @@ $'\001'"ACTION pokes ${IRC_USER}"$'\001') annna-say "$(… | |
| | head -n 1)" | |
| outfile="/br/gopher/midi/${midifile##*/}.ogg" | |
| midi-play "$midifile" >"$outfile" && annna-say "${IRC_CMD_USER}, gophe… | |
| +"${IRC_USER}, please 3d "*) | |
| + args=$(echo ${IRC_PRIVMSG_TEXT} | cut -d' ' -f 4-) | |
| + outfile=$(blender-effect $args) | |
| + annna-say "${IRC_CMD_USER}, gophers://bitreich.org/I/memecache/3d/${ou… | |
| +# https://ednaundharvey.fandom.com/de/wiki/Droggelbecher | |
| +"${IRC_USER}, droggelbecher"*) annna-say "${IRC_CMD_USER}, Droggelbecher!";; | |
| +"${IRC_USER}, thanks"*|"${IRC_USER}, thx"*) annna-say "${IRC_CMD_USER}, you're… | |
| +"${IRC_USER}, please simulate "*" simulator"*) | |
| + q="${IRC_PRIVMSG_TEXT#* please simulate }" | |
| + q="${q% simulator*}" | |
| + outpath="/br/gopher/p/" | |
| + { | |
| + if outfile="$(simulate-simulator "$q")" | |
| + then | |
| + mv "${outfile}" "${outpath}/" | |
| + annna-say "${IRC_CMD_USER}, gophers://bitreich.org/I/p… | |
| + fi | |
| + } & ;; | |
| +"${IRC_USER}, can "*" certify itself?") | |
| + q="${IRC_PRIVMSG_TEXT#* can }" | |
| + q="${q% certify*}" | |
| + { | |
| + # host:port is needed for tlsgrab | |
| + curi="$(tlsgrab "${q}")" | |
| + if [ -n "${curi}" ]; | |
| + then | |
| + annna-say "${IRC_CMD_USER}, let us see the certificate… | |
| + fi | |
| + } & ;; | |
| +"${IRC_USER}, please mine "*" bitreichcoin"*) | |
| + q="${IRC_PRIVMSG_TEXT#* please mine }" | |
| + q="${q% bitreichcoin*}" | |
| + curi="$(bitreichcoin "$q" | /br/bin/bitreich-paste)" | |
| + annna-say "${IRC_CMD_USER}, please don't spend it all at once: ${curi}… | |
| +"${IRC_USER}, please hug me.") annna-say "$(echo -e '\001')ACTION hugs ${IRC_C… | |
| +"${IRC_USER}, please hug "*" for me.") | |
| + huggee="${IRC_PRIVMSG_TEXT#* please hug }" | |
| + huggee="${huggee% for me*}" | |
| + [ -n "${huggee}" ] && annna-say "$(echo -e '\001')ACTION hugs ${huggee… | |
| +"${IRC_USER}, how many fucks were given?") annna-say "${IRC_CMD_USER}, current… | |
| +"${IRC_USER}, please slam the door.") annna-say "${IRC_CMD_USER}, *BANG*";; | |
| +"${IRC_USER}, what is my credit score?") annna-say "${IRC_CMD_USER}, your cred… | |
| +"${IRC_USER}, please give me a cookie.") | |
| + cookie="$(cookie)" | |
| + [ -n "${cookie}" ] && annna-say "$(echo -e '\001')ACTION gives ${IRC_C… | |
| +"${IRC_USER}, please help"*) annna-say -c "${IRC_CMD_USER}" "See git://bitreic… | |
| +"${IRC_USER}, please meme meme meme me"*) | |
| + randomtag=2 | |
| + 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 "${tagname}: ${taguri}" | |
| + randomtag=$((randomtag - 1)) | |
| + done;; | |
| +"${IRC_USER}, what's the wheelchair shooter meme again?") | |
| + tagname="#scrollby" | |
| + tagline="$(printf "%s\n" "$(hashtags)" | grep "^${tagname} ")" | |
| + tagname="$(printf "%s\n" "${tagline}" | cut -d ' ' -f 1)" | |
| + taguri="$(printf "%s\n" "${tagline}" | cut -d ' ' -f 2-)" | |
| + annna-say "${tagname}: ${taguri}";; | |
| +"${IRC_USER}, TIL "*|"${IRC_USER}, til "*) | |
| + minimum_learned_len=12 | |
| + offset=$(( ${#IRC_USER} + 6 )) | |
| + learned="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" \ | |
| + | cut -c $offset- \ | |
| + | sed 's,\t, ,g')" | |
| + if [ ${#learned} -le $minimum_learned_len ]; | |
| + then | |
| + annna-say "${IRC_CMD_USER}, can you explain better what you le… | |
| + else | |
| + result="$(til ${IRC_CMD_USER} "${learned}")" | |
| + if [ $? -eq 0 ]; | |
| + then | |
| + annna-say "${IRC_CMD_USER}, ${result}" | |
| + fi | |
| + fi;; | |
| +"${IRC_USER}, what have I learned?") | |
| + if result=$(til-user ${IRC_CMD_USER}); | |
| + then | |
| + annna-say "${IRC_CMD_USER}, ${result}" | |
| + fi;; | |
| +esac | |
| + | |
| +for person in "${!personalities[@]}"; | |
| +do case "${IRC_PRIVMSG_TEXT,,}" in | |
| +"${person}, "*) | |
| + personality="${personalities[${person}]}" | |
| + preprompt="$(cat ${ANNNA_MODBASE}/prompt-agents/${personality}.prompt.… | |
| + prompt="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -d' ' -f 2- | sed … | |
| + { annna-say "$(gpt "System: ${preprompt}\n User: ${prompt}\n Bot:")" }… | |
| +esac done | |
| + | |
| +case "${IRC_PRIVMSG_TEXT}" in | |
| "${IRC_USER}, please antidepressant #"*|\ | |
| "${IRC_USER}, please amplify #"*|\ | |
| "${IRC_USER}, please amsterdamify #"*|\ | |
| @@ -1272,94 +1298,6 @@ $'\001'"ACTION pokes ${IRC_USER}"$'\001') annna-say "$(e… | |
| [ -s "${outpath}" ] && annna-say "${recipient}, gophers://bitr… | |
| } & | |
| exit 0;; | |
| -"${IRC_USER}, please 3d "*) | |
| - args=$(echo ${IRC_PRIVMSG_TEXT} | cut -d' ' -f 4-) | |
| - outfile=$(blender-effect $args) | |
| - annna-say "${IRC_CMD_USER}, gophers://bitreich.org/I/memecache/3d/${ou… | |
| -# https://ednaundharvey.fandom.com/de/wiki/Droggelbecher | |
| -"${IRC_USER}, droggelbecher"*) annna-say "${IRC_CMD_USER}, Droggelbecher!";; | |
| -"${IRC_USER}, thanks"*|"${IRC_USER}, thx"*) annna-say "${IRC_CMD_USER}, you're… | |
| -"${IRC_USER}, please simulate "*" simulator"*) | |
| - q="${IRC_PRIVMSG_TEXT#* please simulate }" | |
| - q="${q% simulator*}" | |
| - outpath="/br/gopher/p/" | |
| - { | |
| - if outfile="$(simulate-simulator "$q")" | |
| - then | |
| - mv "${outfile}" "${outpath}/" | |
| - annna-say "${IRC_CMD_USER}, gophers://bitreich.org/I/p… | |
| - fi | |
| - } & ;; | |
| -"${IRC_USER}, can "*" certify itself?") | |
| - q="${IRC_PRIVMSG_TEXT#* can }" | |
| - q="${q% certify*}" | |
| - { | |
| - # host:port is needed for tlsgrab | |
| - curi="$(tlsgrab "${q}")" | |
| - if [ -n "${curi}" ]; | |
| - then | |
| - annna-say "${IRC_CMD_USER}, let us see the certificate… | |
| - fi | |
| - } & ;; | |
| -"${IRC_USER}, please mine "*" bitreichcoin"*) | |
| - q="${IRC_PRIVMSG_TEXT#* please mine }" | |
| - q="${q% bitreichcoin*}" | |
| - curi="$(bitreichcoin "$q" | /br/bin/bitreich-paste)" | |
| - annna-say "${IRC_CMD_USER}, please don't spend it all at once: ${curi}… | |
| -"${IRC_USER}, please hug me.") annna-say "$(echo -e '\001')ACTION hugs ${IRC_C… | |
| -"${IRC_USER}, please hug "*" for me.") | |
| - huggee="${IRC_PRIVMSG_TEXT#* please hug }" | |
| - huggee="${huggee% for me*}" | |
| - [ -n "${huggee}" ] && annna-say "$(echo -e '\001')ACTION hugs ${huggee… | |
| -"${IRC_USER}, how many fucks were given?") annna-say "${IRC_CMD_USER}, current… | |
| -"${IRC_USER}, please slam the door.") annna-say "${IRC_CMD_USER}, *BANG*";; | |
| -"${IRC_USER}, what is my credit score?") annna-say "${IRC_CMD_USER}, your cred… | |
| -"${IRC_USER}, please give me a cookie.") | |
| - cookie="$(cookie)" | |
| - [ -n "${cookie}" ] && annna-say "$(echo -e '\001')ACTION gives ${IRC_C… | |
| -"${IRC_USER}, please help"*) annna-say -c "${IRC_CMD_USER}" "See git://bitreic… | |
| -"${IRC_USER}, please meme meme meme me"*) | |
| - randomtag=2 | |
| - 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 "${tagname}: ${taguri}" | |
| - randomtag=$((randomtag - 1)) | |
| - done;; | |
| -"${IRC_USER}, what's the wheelchair shooter meme again?") | |
| - tagname="#scrollby" | |
| - tagline="$(printf "%s\n" "$(hashtags)" | grep "^${tagname} ")" | |
| - tagname="$(printf "%s\n" "${tagline}" | cut -d ' ' -f 1)" | |
| - taguri="$(printf "%s\n" "${tagline}" | cut -d ' ' -f 2-)" | |
| - annna-say "${tagname}: ${taguri}";; | |
| -"${IRC_USER}, TIL "*|"${IRC_USER}, til "*) | |
| - minimum_learned_len=12 | |
| - offset=$(( ${#IRC_USER} + 6 )) | |
| - learned="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" \ | |
| - | cut -c $offset- \ | |
| - | sed 's,\t, ,g')" | |
| - if [ ${#learned} -le $minimum_learned_len ]; | |
| - then | |
| - annna-say "${IRC_CMD_USER}, can you explain better what you le… | |
| - else | |
| - result="$(til ${IRC_CMD_USER} "${learned}")" | |
| - if [ $? -eq 0 ]; | |
| - then | |
| - annna-say "${IRC_CMD_USER}, ${result}" | |
| - fi | |
| - fi;; | |
| -"${IRC_USER}, what have I learned?") | |
| - if result=$(til-user ${IRC_CMD_USER}); | |
| - then | |
| - annna-say "${IRC_CMD_USER}, ${result}" | |
| - fi;; | |
| esac | |
| printf '%s' "${IRC_PRIVMSG_TEXT}" | awk -v taglimit="$printnhashtags" ' |