faq 384 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env bash
  2. # mlaine@sdfeu
  3. source '../say.sh'
  4. cd '../faqfiles'
  5. nick="$1"
  6. chan="$2"
  7. args=("${@:3}")
  8. faq="${args[0]}"
  9. if [[ "${#args[@]}" -ge 2 && "${args[-2]}" = '>' &&
  10. ! "${args[-1]}" =~ '#' ]]; then
  11. chan="${args[-1]}"
  12. fi
  13. if [[ -f "$faq" ]]; then
  14. readarray -t msg < "$faq"
  15. else
  16. faqs=(*)
  17. msg="Available topics: ${faqs[*]}"
  18. fi
  19. say "$chan" "${msg[@]}"