#!/usr/bin/env bash # say - post a short message viewable in the fingerverse # Run "say -h" for usage. # Copyright 2026 https://640kb.neocities.org # Blue Oak Model License 1.0.0 # 27sep2026: fixed issue with long lines. Using awk instead of sed now. # 26sep2026: Initial release set -u # =========================================================================== # CONFIGURATION: START # =========================================================================== # If HEAD is blank (HEAD=""), the full message output is shown. # If HEAD is a number (HEAD="25"), only the first N lines are shown. HEAD="25" # Enter a stdout finger client: nf, reiver, finger.sh, dfinger, lindax, etc. # https://640kb.neocities.org/fingerverse/index.html FINGER="nf" # =========================================================================== # CONFIGURATION: END # =========================================================================== usage() { cat <<'EOF' say is a front-end script for say@happynetbox.com - a finger-oriented open chat service that requires no account to post or read. Usage: say "message..." Post MESSAGE to the say chat server say -h | --help Show this help text say --say Display messages posted by users - Reformats the output for terminal-friendly width - Requires: wget, awk To begin, edit the configuration at the top of this script: - FINGER = your default stdout finger client - HEAD = number of lines to display from server output EOF } format_say() { awk ' /^note: you can only send 1 message every 6 hours!$/ { print print "" next } /^[┌└]/ { next } /^│ / { line = $0 sub(/^│ /, "", line) sub(/ *│$/, "", line) sub(/^ +/, "", line) sub(/ +$/, "", line) if (match(line, /[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]$/)) { ts = substr(line, RSTART) body = substr(line, 1, RSTART-1) sub(/ +$/, "", body) if (msg == "") { msg = body } else { msg = msg " " body } if (match(msg, /^([^:]+): /)) { user = substr(msg, RSTART, RLENGTH-2) text = substr(msg, RSTART+RLENGTH) printf "%s (%s): %s\n", user, ts, text } else { print msg " (" ts ")" } msg = "" } else { if (msg == "") { msg = line } else { msg = msg " " line } } next } { print } ' } show_say() { if [[ -n "$HEAD" ]]; then "${FINGER:-finger}" say@happynetbox.com | format_say | head -n "$HEAD" return "${PIPESTATUS[0]}" else "${FINGER:-finger}" say@happynetbox.com | format_say fi } post_message() { local url="https://say.awildergoose.com/p/${1}" if [[ -n "$HEAD" ]]; then echo wget -qO- "$url" | format_say | head -n "$HEAD" echo return "${PIPESTATUS[0]}" else echo wget -qO- "$url" | format_say echo fi } case "${1:-}" in -h|--help) usage ;; --say) show_say ;; "") usage >&2; exit 1 ;; *) post_message "$*" ;; esac