#!/usr/bin/env sh . /home/zgrep/offtopiabday/happybot/common.sh dir="happybot/compose" irc | while read -r n m; do if hreg '^(?:@?happybot[:,] |!)compose(?:key)? (.+)$' "$m"; then query="$(m 1)" echo "Got: $query" lines="$(grep -Fin -e "$query" "$dir/chars.txt" | sed 's/:.*$/p/' | tr '\n' ';')" if [ -z "$lines" ]; then echo "| Did not match chars.txt." lines="$(grep -Fin -e "$query" "$dir/comments.txt" | sed 's/:.*$/p/' | tr '\n' ';')" fi echo "| Lines: $lines" if [ -z "$lines" ]; then echo "| No results." var "$n: No results." | zwsp | say else var "$n: $(sed -n "$lines" "$dir/sequences.txt" | sed 's/$/ | /' | tr -d '\n' | sed 's/ | $/\n/')" | zwsp | say fi fi done;