Update to handle non-int64 IDs
Pleroma/Akkoma and GotoSocial use opaque IDs rather than `int64`s like
Mastodon which means that `madon` can't talk to either of those.
This commit updates everything that can be an ID to `madon.ActivityID`
which is an alias for `string` - can't create a specific type for it
since there's more than a few places where they're concatenated directly
to strings for URLs, etc. Which means it could just as easily be a
direct `string` type itself but I find that having distinct types can
often make the code more readable and understandable.
One extra bit is that `statusOpts` has grown a `_hasReplyTo` boolean
to indicate whether the `--in-reply-to` flag was given or not because
we can't distinguish because "empty because default" or "empty because
given and empty". Another way around this would be to set the default
to some theoretically impossible or unlikely string but you never
know when someone might spin up an instance where, e.g., admin posts
have negative integer IDs.
#! /bin/bash
# (Using bash or zsh for the <() process substitution feature...)
#
# Sample script using madonctl (0.4+), use --help for usage.
# This script uses the 'combine' utility (from the moreutils package in
# Debian).
#
# MiKael, 2017-04
set -e
usage() {
echo "Usage: $0 following_only|followers_only|both"
}
# Check madonctl is in the PATH
command -v madonctl >/dev/null 2>&1 || {
echo "Error: madonctl not found">&2
exit 1
}
# Check combine command (from the moreutils package)
command -v combine >/dev/null 2>&1 || {
echo "Error: combine not found">&2
exit 1
}
# Get our account ID (not needed anymore as of 0.4.0)
# me="$(madonctl account show --template '{{.id}}')"
# $1 = following/followers
getAccountFollow() {
TEMPL='{{.id}}{{"\n"}}'
madonctl accounts --all "$1" --template "$TEMPL"
}
displayAccount() {
id=$1
madonctl account show --account-id "$id" \
--template '{{printf "%s\t%s\n" .acct .display_name}}'
}
combineOutput() {
case $1 in
(both)
combine <(getAccountFollow following) and <(getAccountFollow followers)
;;
(following_only)
combine <(getAccountFollow following) not <(getAccountFollow followers)
;;
(followers_only)
combine <(getAccountFollow followers) not <(getAccountFollow following)
;;
esac
}
case $1 in
(both|following_only|followers_only)
combineOutput "$1" | while read acccountID; do
displayAccount "$acccountID"
done
;;
(help|--help|-h)
usage
;;
(*)
usage>&2
exit 1
esac