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