mlblive-mastodon-scripts/mlbposthighlights.sh

38 lines
569 B
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -e
while getopts 'd:a:' opt
do
case $opt in
d)
db=$OPTARG
;;
a)
account=$OPTARG
;;
?)
exit 1
;;
esac
done
if [[ -z $db ]]
then
echo "$0:" '-d is required' >&2
exit 1
fi
if [[ -z $account ]]
then
echo "$0:" '-a is required' >&2
exit 1
fi
get='print $3 | "xargs curl >" $2; close("xargs curl >" $2)'
fmt='printf "%s\n\n#baseball #highlights\n", $1'
post='"toot post -m " $2'
post+="\" --using $account\""
del='print $2 | "xargs rm"'
sqlite3 $db < posthighlights.sql | awk -F  "{$get; $fmt | $post; close($post); $del}"