split channel-specific content to its own script - annna - Annna the nice frien… | |
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
--- | |
commit aea4bdf3acd506f2486022fac38f2cd7ea3d1c86 | |
parent 943d44215057ce4f29d99c06c30be236fcfff065 | |
Author: Josuah Demangeon <[email protected]> | |
Date: Mon, 8 Mar 2021 00:41:11 +0100 | |
split channel-specific content to its own script | |
Signed-off-by: Annna Robert-Houdin <[email protected]> | |
Diffstat: | |
A annna-message-common | 765 +++++++++++++++++++++++++++++… | |
A annna-message-radio | 24 ++++++++++++++++++++++++ | |
M annna-start-services | 791 +----------------------------… | |
3 files changed, 791 insertions(+), 789 deletions(-) | |
--- | |
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! ⤠… | |
+ ;; | |
+ *\|\ Cloudflare*) | |
+ annna-say -c "${channel}" "Mind your own busin… | |
+ 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\.\)\{… | |
+ 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,m… | |
+ then | |
+ nuri="$(printf '%s\n' "${uri}" | sed -e "s;.*e… | |
+ 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… | |
+ nuris="old.reddit: ${nuri}" | |
+ fetch-uri "${nuri}" > "${tmpf}" | |
+ if [ -n "${uri#*www.reddit.com/r/*}" ]; | |
+ then | |
+ subreddit="$(printf '%s\n' "${uri}" | cut -d /… | |
+ post="$(printf '%s\n' "${uri}" | cut -d / -f 7… | |
+ if [ -n "${post}" ]; | |
+ then | |
+ guri="gopher://gopherddit.com/1/cgi-bi… | |
+ else | |
+ guri="gopher://gopherddit.com/1/cgi-bi… | |
+ 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/bi… | |
+ fi | |
+ outputstr="${outputstr} content: ${curi} ;" | |
+ fi | |
+ | |
+ [ -n "${nuris}" ] && outputstr="${outputstr} ${nuris} … | |
+ [ -n "${urititle}" ] && outputstr="${outputstr} title:… | |
+ [ -n "${suri}" ] && outputstr="${outputstr} screen: ${… | |
+ [ -n "${sturi}" ] && outputstr="${outputstr} subtitles… | |
+ 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… | |
+ ;; | |
+"${botname}, what is "*) | |
+ word="$(printf "%s\n" "${text}" | cut -c 16-)" | |
+ case "$word" in | |
+ *\?) | |
+ word="$(printf "%s\n" "${word}" | cut -c -"$(($(expr length "$… | |
+ ;; | |
+ 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-pa… | |
+ ;; | |
+ 20) | |
+ puri="No matches found." | |
+ ;; | |
+ 1) | |
+ puri="Parse error." | |
+ ;; | |
+ *) | |
+ puri="Parazyd destroyed the server. Nothing to see her… | |
+ ;; | |
+ 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/… | |
+ ;; | |
+"${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 ma… | |
+ { | |
+ 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.ip… | |
+ } & | |
+ ;; | |
+"${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 mor… | |
+ 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 … | |
+ ;; | |
+"${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}' … | |
+ 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… | |
+ 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 "$… | |
+ ;; | |
+ 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-pa… | |
+ 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 … | |
+ ;; | |
+"${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 "$… | |
+ ;; | |
+ 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-pa… | |
+ 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 "$… | |
+ ;; | |
+ 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 \(.… | |
+ lovedistance="$(printf "%s * 100\n" "$(fstrcmp ${words})" | bc… | |
+ 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… | |
+ 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']'… | |
+ 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 her… | |
+ ;; | |
+"${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://adam… | |
+ ;; | |
+"${botname}, how many people died of corona?") | |
+ annna-say -c "${channel}" "${user}, too many. :( Please see yourself: … | |
+ ;; | |
+"${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-pas… | |
+ annna-say -c "${channel}" "Here are the victims: ${puri}" | |
+ ;; | |
+"${botname}, please distro-hop with me.") | |
+ ndistro="$(curl -s 'https://distrowatch.com/dwres.php?resource=popular… | |
+ | 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/memecac… | |
+ ;; | |
+"${botname}, release the Quacken!") | |
+ annna-say -c "${channel}" "Quack Quack! gopher://bitreich.org/9/memeca… | |
+ ;; | |
+"${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 Gunt… | |
+ ;; | |
+"${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 th… | |
+ sleep 0.5 | |
+ annna-say -c "${user}" "»please show me your memes.« gets you al… | |
+ sleep 0.5 | |
+ annna-say -c "${user}" "»please show me the victims.« gets you a… | |
+ sleep 0.5 | |
+ annna-say -c "${user}" "»can you show me the uptime please?« get… | |
+ 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.�… | |
+ sleep 0.5 | |
+ annna-say -c "${user}" "»please tell me your favourite flower.«,… | |
+ sleep 0.5 | |
+ annna-say -c "${user}" "»please tell me your favourite color.«, … | |
+ 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 pleas… | |
+ 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 listi… | |
+ ;; | |
+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-not… | |
+ ;; | |
+*RFC[0-9]*) | |
+ rfcname="$(printf "%s\n" "${text}" | sed 's,.*\(RFC[0-9]*\).*,\1,' | t… | |
+ annna-say -c "${channel}" "${rfcname}: ftp://ftp.rfc-editor.org/in-not… | |
+ ;; | |
+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,… | |
+ ;; | |
+"${botname}, please give me the count of online users.") | |
+ annna-say -c "${channel}" "$(hostname): $(who -q | tail -n 1 | cut -d'… | |
+ ;; | |
+"${botname}, please update the phlog index.") | |
+ phlog-index > /dev/null 2>&1 | |
+ annna-say -c "${channel}" "Thanks! Your request has been fulfilled wit… | |
+ ;; | |
+esac | |
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, ${… | |
+ annna-say -c "${user}" "»please help.« gives you this help listing, … | |
+ ;; | |
+esac | |
+ | |
+annna-message-common "${channel}" "${user}" "${text}" | |
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 paraz… | |
-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… | |
-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*|*G�nther*) | |
- annna-say -c "${channel}" "Oh Gunther!… | |
- ;; | |
- *\|\ Cloudflare*) | |
- annna-say -c "${channel}" "Mind your o… | |
- 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,\.,\\\.,… | |
- nuri="$(printf "%s\n" "${uri}" | sed "s;\(mobi… | |
- 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,ti… | |
- then | |
- nuri="$(printf '%s\n' "${uri}" | sed -… | |
- nuris="$(printf 'gopherpedia: %s\n' "$… | |
- fetch-uri "${nuri}" > "${tmpf}" | |
- nocuri=0 | |
- fi | |
- ;; | |
- *www.reddit.com*) | |
- nuri="$(printf '%s\n' "${uri}" | sed "s;www.re… | |
- nuris="old.reddit: ${nuri}" | |
- fetch-uri "${nuri}" > "${tmpf}" | |
- if [ -n "${uri#*www.reddit.com/r/*}" ]; | |
- then | |
- subreddit="$(printf '%s\n' "${uri}" | … | |
- post="$(printf '%s\n' "${uri}" | cut -… | |
- if [ -n "${post}" ]; | |
- then | |
- guri="gopher://gopherddit.com/… | |
- else | |
- guri="gopher://gopherddit.com/… | |
- fi | |
- nuris="${nuri} ; gopherdit: ${guri}" | |
- fi | |
- nocuri=0 | |
- ;; | |
- *github.com/*/blob/*) | |
- urltitle="" | |
- nuris="$(printf '%s' "${uri}" | sed 's/blob/ra… | |
- 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=$… | |
- 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}" … | |
- fi | |
- outputstr="${outputstr} content: ${cur… | |
- fi | |
- | |
- [ -n "${nuris}" ] && outputstr="${outputstr} $… | |
- [ -n "${urititle}" ] && outputstr="${outputstr… | |
- [ -n "${suri}" ] && outputstr="${outputstr} sc… | |
- [ -n "${sturi}" ] && outputstr="${outputstr} s… | |
- 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://bitr… | |
- ;; | |
- "${botname}, what is "*) | |
- word="$(printf "%s\n" "${text}" | cut -c 16-)" | |
- case "$word" in | |
- *\?) | |
- word="$(printf "%s\n" "${word}" | cut -c -"$(($(expr l… | |
- ;; | |
- 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>/de… | |
- derr2="$?" | |
- [ $derr2 -ne $derr ] && derr=$derr2 | |
- fi | |
- case "$derr" in | |
- 0|21) | |
- puri="$(printf "%s" "${dresult}" | /br/bin/bit… | |
- ;; | |
- 20) | |
- puri="No matches found." | |
- ;; | |
- 1) | |
- puri="Parse error." | |
- ;; | |
- *) | |
- puri="Parazyd destroyed the server. Nothing to… | |
- ;; | |
- 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... ${… | |
- fi | |
- rm ${tmpf} 2>/dev/null | |
- ;; | |
- "${botname}, play despacito plz.") | |
- annna-say -c "${channel}" "${user}, gopher://bitreich.org/9/me… | |
- ;; | |
- "${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 fo… | |
- { | |
- cd $HOME/bin/modules/ip-art; | |
- # Lock, so only one annna process manipulates eth0. | |
- flock $HOME/bin/modules/ip-art -c "./display-file.sh i… | |
- } & | |
- ;; | |
- "${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… | |
- 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 ha… | |
- ;; | |
- "${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++) pri… | |
- 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… | |
- 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-pa… | |
- 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, ,… | |
- case "$word" in | |
- *\?) | |
- word="$(printf "%s\n" "${word}" | cut -c -"$(($(expr l… | |
- ;; | |
- 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/bit… | |
- 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… | |
- annna-say -c "${channel}" "${user}, I Obey my master! long liv… | |
- ;; | |
- "${botname}, sacrifice"*) | |
- # Emulate https://threats.kaspersky.com/en/threat/IRC-Worm.DOS… | |
- annna-say -c "${channel}" "${user}, Your word is my command, P… | |
- ;; | |
- "${botname}, textsynth is "*) | |
- word="$(printf "%s\n" "${text}" | cut -c 21- | sed 's,\t, ,… | |
- case "$word" in | |
- *\?) | |
- word="$(printf "%s\n" "${word}" | cut -c -"$(($(expr l… | |
- ;; | |
- esac | |
- | |
- # Do in background, because read is very slow. | |
- { | |
- dresult="$(textsynth-complete -r "${word}")" | |
- if [ -n "${dresult}" ]; | |
- then | |
- puri="$(printf "%s" "${dresult}" | /br/bin/bit… | |
- 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, ,… | |
- case "$word" in | |
- *\?) | |
- word="$(printf "%s\n" "${word}" | cut -c -"$(($(expr l… | |
- ;; | |
- 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: ${ne… | |
- fi | |
- | |
- ;; | |
- "${botname}, are "*) | |
- case "${text}" in | |
- *" in love?") | |
- words="$(printf "%s\n" "${text}" | sed 's,.*are \(.*\)… | |
- lovedistance="$(printf "%s * 100\n" "$(fstrcmp ${words… | |
- 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… | |
- else | |
- annna-say -c "${channel}" "${user}, have you tried ${g… | |
- fi | |
- ;; | |
- "${botname}, I'm gopher bored.") | |
- randomlink="$(/br/bin/bitreich-lawn-random-link)" | |
- linktype="$(printf "%s\n" "${randomlink}" | cut -d '|' -f1 | c… | |
- 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 | c… | |
- 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" "$l… | |
- fi | |
- annna-say -c "${channel}" "$outtext" | |
- ;; | |
- "${botname}, wb.") | |
- annna-say -c "${channel}" "${user}, ty! I am so happy to be he… | |
- ;; | |
- "${botname}, welcome back.") | |
- annna-say -c "${channel}" "${user}, thank you! I am so happy t… | |
- ;; | |
- "${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 ran… | |
- annna-say -c "${channel}" "You could have ${newsstr}! Be caref… | |
- ;; | |
- "${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/bitrei… | |
- annna-say -c "${channel}" "${user}, your future is here: ${pur… | |
- ;; | |
- "${botname}, how many memes do you know?") | |
- annna-say -c "${channel}" "I know $(hashtagcount) memes: gophe… | |
- ;; | |
- "${botname}, how many people died of corona?") | |
- annna-say -c "${channel}" "${user}, too many. :( Please see yo… | |
- ;; | |
- "${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/bitr… | |
- annna-say -c "${channel}" "Here are the victims: ${puri}" | |
- ;; | |
- "${botname}, please distro-hop with me.") | |
- ndistro="$(curl -s 'https://distrowatch.com/dwres.php?resource… | |
- | grep phr2 \ | |
- | sed 's,.*href="\(.*\)".*,\1,' \ | |
- | sort | uniq | shuf -n 1)" | |
- annna-say -c "${channel}" "How about https://distrowatch.com/$… | |
- ;; | |
- "${botname}, please show me your Macron.") | |
- annna-say -c "${channel}" "gopher://bitreich.org/0/ascii/macro… | |
- ;; | |
- "${botname}, release the Kraken!") | |
- annna-say -c "${channel}" "Here it is! gopher://bitreich.org/0… | |
- ;; | |
- "${botname}, release the Quacken!") | |
- annna-say -c "${channel}" "Quack Quack! gopher://bitreich.org/… | |
- ;; | |
- "${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 flo… | |
- ;; | |
- "${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-… | |
- 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! :-… | |
- fi | |
- ;; | |
- "${botname}, please tell me who is your favourite pleasure man.") | |
- annna-say -c "${channel}" "My favourite pleasure man is of cou… | |
- ;; | |
- "${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 slee… | |
- annna-say -c "${user}" "»how many memes do you know?«gets yo… | |
- sleep 0.5 | |
- annna-say -c "${user}" "»please show me your memes.« gets yo… | |
- sleep 0.5 | |
- annna-say -c "${user}" "»please show me the victims.« gets y… | |
- sleep 0.5 | |
- annna-say -c "${user}" "»can you show me the uptime please?«… | |
- 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 u… | |
- sleep 0.5 | |
- annna-say -c "${user}" "»please tell me your favourite flower… | |
- sleep 0.5 | |
- annna-say -c "${user}" "»please tell me your favourite color.… | |
- 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.«, ${… | |
- 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«, ${… | |
- sleep 0.5 | |
- annna-say -c "${user}" "»please tell me who is your favourite… | |
- 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 l… | |
- ;; | |
- 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]*\).*,… | |
- annna-say -c "${channel}" "${rfcname}: ftp://ftp.rfc-editor.or… | |
- ;; | |
- *RFC[0-9]*) | |
- rfcname="$(printf "%s\n" "${text}" | sed 's,.*\(RFC[0-9]*\).*,… | |
- annna-say -c "${channel}" "${rfcname}: ftp://ftp.rfc-editor.or… | |
- ;; | |
- 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}" && con… | |
- 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% *}: ${ta… | |
- 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 |… | |
- ;; | |
- "${botname}, please give me the count of online users.") | |
- annna-say -c "${channel}" "$(hostname): $(who -q | tail -n 1 |… | |
- ;; | |
- "${botname}, please update the phlog index.") | |
- phlog-index > /dev/null 2>&1 | |
- annna-say -c "${channel}" "Thanks! Your request has been fulfi… | |
- ;; | |
- 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 … | |
- return # stop here | |
- ;; | |
- ${botname}, please help.) | |
- annna-say -c "${user}" "»next please.« gets the playlist fur… | |
- annna-say -c "${user}" "»please help.« gives you this help l… | |
- ;; | |
- 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}" "${… | |
;; | |
*) | |
- annna_common "${channel}" "${user}" "${text}" | |
+ annna-message-common "${channel}" "${user}" "$… | |
;; | |
esac | |
done |