summary refs log tree commit diff
path: root/etc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--etc/pronouns/.gitignore2
-rw-r--r--etc/pronouns/bot.sh57
2 files changed, 59 insertions, 0 deletions
diff --git a/etc/pronouns/.gitignore b/etc/pronouns/.gitignore
new file mode 100644
index 00000000..facfb3f3
--- /dev/null
+++ b/etc/pronouns/.gitignore
@@ -0,0 +1,2 @@
+access_token
+[1-9]*
diff --git a/etc/pronouns/bot.sh b/etc/pronouns/bot.sh
new file mode 100644
index 00000000..aa613bd9
--- /dev/null
+++ b/etc/pronouns/bot.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+set -eu
+
+Instance=https://mstdn.isometry.group
+
+if ! test -f access_token; then
+	echo 'No access_token!' >&2
+	exit 1
+fi
+
+access_token=$(cat access_token)
+
+account_id=$(
+	curl -Ss \
+		-H "Authorization: Bearer ${access_token}" \
+		${Instance}/api/v1/accounts/verify_credentials |
+	jq -r .id
+)
+
+# XXX: no pagination because I don't expect this to ever have over 80 followers
+followers=$(
+	curl -Ss \
+		-H "Authorization: Bearer ${access_token}" \
+		"${Instance}/api/v1/accounts/${account_id}/followers?limit=80" |
+	jq -r 'map(select(.acct | contains("@") | not)) | .[].id'
+)
+
+for follower_id in $followers 112284333737697665; do
+	account=$(
+		curl -Ss \
+			-H "Authorization: Bearer ${access_token}" \
+			${Instance}/api/v1/accounts/${follower_id}
+	)
+	username=$(printf '%s' "${account}" | jq -r .username)
+	pronouns=$(
+		printf '%s' "${account}" |
+		jq -r '
+			.fields |
+			map(select(.name | test("^prono(un|m)s?[?]?$"; "i"))) |
+			.[].value
+		'
+	)
+	if ! test -f $follower_id; then
+		printf '%s' "${pronouns}" >$follower_id
+		continue
+	fi
+	old_pronouns=$(cat $follower_id)
+	if [ "${pronouns}" != "${old_pronouns}" ]; then
+		curl -Ss -X POST \
+			-H "Authorization: Bearer ${access_token}" \
+			-F visibility=unlisted \
+			--form-string \
+			"status=@${username} has changed pronouns to: ${pronouns}" \
+			${Instance}/api/v1/statuses >/dev/null
+		printf '%s' "${pronouns}" >$follower_id
+	fi
+done
der'>2018-09-13Rewrite UI againJune McEnroe The persistent topic is gone and the status line is now at the top. The status formatting still needs to be reworked. I also want to try showing the nick in the input window so it really looks like your next message. 2018-09-12Add note about C-oJune McEnroe Why are there so few well usable ctrl key bindings? 2018-09-12Use formatParse split to position input cursorJune McEnroe 2018-09-12Factor out IRC formatting parsingJune McEnroe 2018-09-11Add /help equivalent to /manJune McEnroe 2018-09-11Don't render every PM as a pingJune McEnroe 2018-09-11Add urlOpenMatchJune McEnroe 2018-09-10Depend on man.sh for chroot.tar targetJune McEnroe 2018-09-10Set LESSSECURE=1 in man.shJune McEnroe Ridiculous. 2018-09-10Add /man commandJune McEnroe 2018-09-10Install man page in chrootJune McEnroe 2018-09-10Install man pageJune McEnroe 2018-09-10Split keys into subsections and document colorsJune McEnroe 2018-09-10Add "blank" lines to chatte.1June McEnroe 2018-09-10Document key bindings in chatte.1June McEnroe 2018-09-08Document slash commands in chatte.1June McEnroe