TootRain since 1.7.3 supports both AppleScript and Shortcuts.
You can find the availble commands from Script Editor. Here is an example of showing a status via AppleScript:
tell application "TootRain"
show status "Hello world"
end tell
The body supports <img src=...>
tag, you can also specify the avatar URL like this:
tell application "TootRain"
show status "Hello<img src=\"https://is-he.re/emoji/lihkg/big-smile.gif\">world" avatar "https://is-he.re/emoji/lihkg/cow-ball.gif"
end tell
Since OS X 10.10, scripting is also available in JavaScript, so you can write code like this:
TootRain = Application("TootRain")
TootRain.showStatus("hello", {"avatar":"https://is-he.re/emoji/lihkg/big-smile.gif"})
You can also access current visible statuses via the status
element.
tell application "TootRain"
every status
end tell
This gives you an array of status, with the following properties
id
body
- The parsed body, HTML tags are stripped out.rawBody
- The raw text of the status, posts from Mastodon usually contains HTML like <p>hello</p>
username
screenName
While there’s no API to get a script triggered when there’s a new status, it’s always possible to poll the status
array. Here is an example of a script, automatically reading out the body whenever there’s a new status.
tell application "TootRain"
set lastHandled to ""
repeat
set allStatuses to every status
if allStatuses's length is greater than 0 then
set lastStatus to the last item of allStatuses
if lastStatus's id is not equal to lastHandled then
set statusBody to lastStatus's body
say statusBody using "Kyoko"
set lastHandled to lastStatus's id
end if
end if
delay 1
end repeat
end tell
Shortcut integration is much simpler, the only command supported is to show status on screen. The text
option support <img src=...>
tags, and the avatar
option is optional.