Idiomdrottning’s homepage

Tooticki

I like toot as a good complement to other ActivityPub clients. It’s friendly for scripting.

I can’t really use the TUI version (maybe there’s some issue with my shell) but I use the CLI interface all the time.

One way I use it is in Emacs shell-mode. I hacked in some Lisp so I can favorite, reblog and even reply right from there; I move the cursor to the body of the post and then hit the key bound to one of these interactive functions. (If I wanna do even more fancy stuff I still can, just typing it in the command line as usual, or for some things I still schlep out another client.)

Here is the elisp:

(defun tooticki-find-id ()
  (interactive)
  (save-excursion
    (beginning-of-line)
    (re-search-forward "^ID ")
    (let ((st (point)))
      (forward-word)
      (buffer-substring-no-properties st (point)))))

(defun tooticki-reply-markdown ()
  (interactive)
  (let* ((id (tooticki-find-id))
	 (topic
	  (string-trim-right
	   (shell-command-to-string
	    (s-concat "toot status --json " id "|jq  .spoiler_text"))))
	 (targs (if (< (length topic) 3) "" (s-concat " -p " topic))))
    (async-shell-command
     (s-concat "toot post -r " id targs))))

(defun tooticki-skele (str)
  (shell-command (s-concat "toot " str " " (tooticki-find-id))))

(defun tooticki-fave ()
  (interactive)
  (tooticki-skele "favourite"))

(defun tooticki-boost ()
  (interactive)
  (tooticki-skele "reblog"))

Except that where I wrote “toot post -r” here, in the version I’ve got bound it’s instead a wrapper around written in zshbrev that tries to guess language (currently doing a really bad job at it since for some reason many emojis trigger false positives making it guess that some English language posts are Swedish) and that offers to post links to linkhut.

One limitation is that it doesn’t pre-populate the reply with @usernames; that’s a work in progress. I currently just manually paste them in. Today I added the feature that it preserves the spoiler text a.k.a. subject line, and a similar route, parsing status --json, could be the ticket for getting the user names in there. One SMOP over the line, sweet Jesus.

Update

Yeah, finding the usernames was possible:

toot-get-usernames () {
	toot status --json $1 | jq -r '..|select(.acct?).acct' |
		mawk '!s[$0]++' | sed 's;^;@;'
}