Spruce idiotbox-roulette. - 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
---
(DIR) commit 655729ca4640b9a201c6e4f4c6415d417d7cbbe6
(DIR) parent f85089535896bfcef536c3a1f33c8e23fa2a7c32
(HTM) Author: eidolon <?>
Date: Tue, 22 Oct 2024 19:08:19 -0400
Spruce idiotbox-roulette.
Signed-off-by: Annna Robert-Houdin <annna@bitreich.org>
Diffstat:
M idiotbox-roulette | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
---
(DIR) diff --git a/idiotbox-roulette b/idiotbox-roulette
@@ -3,18 +3,22 @@
# by: eidolon
# Thanks!
-[ -z "$1" ] && exit 1
-
-printf '/idiotbox.cgi\t%s\r\n' "$1" |
- nc codemadness.org 70 |
- awk -v seed="$RANDOM" '
- BEGIN { FS="\t"; srand(seed) }
+spin() {
+ awk -F "\t" '
+ BEGIN { srand() }
+ function randomidiot(n) {
+ return int(rand() * n)
+ }
+ /^h/ && !/^hAtom/ { out[i++] = $1" "$2 }
+ END {
+ s = out[randomidiot(length(out))]
+ sub(/URL:/, "url: ", s)
+ print substr(s, 2)
+ }'
+}
- /^h/ && !/^hAtom/ { out[i++] = $1" "$2 }
+[ -z "$1" ] && exit 1
- END {
- p = out[int(rand()*length(out))]
- p = substr(p, 2)
- print p
- }
- ' | sed 's,URL:,url: ,'
+nc codemadness.org 70 << _EOF | spin
+$(printf '/idiotbox.cgi\t%s\r\n' "$1")
+_EOF