seen 461 B

1234567891011121314151617181920212223
  1. #!/usr/bin/env bash
  2. # odie@sdf
  3. source '../say.sh'
  4. chan="$2"
  5. nick="$3"
  6. if [[ -n "$nick" && ! "$nick" =~ [^[:alnum:]_-] && "${nick::1}" != '-' ]]; then
  7. read -ra seen <<< "$(grep "^$nick " '../../data/seen')"
  8. if [[ -z "$seen" ]]; then
  9. msg="The user $nick was not found."
  10. else
  11. msg="$nick was last seen on ${seen[@]:1:3} in ${seen[4]}."
  12. fi
  13. else
  14. msg='Please use the following syntax: !seen <nickname>.'
  15. fi
  16. say "$chan" "$msg"