Last active
April 27, 2019 20:17
-
-
Save dkiesow/cf4690114e7af2164e02487099ee4f01 to your computer and use it in GitHub Desktop.
Applescript portion of app that uses rtweet to send automated tweets from Mac keynote
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global extras | |
global lastTweet | |
property okflag : false | |
-- Keynote rTweet 1.0 Damon Kiesow @dkiesow | |
-- Entirely adapted for rtweet from Keynote-Tweet maintained by Alan Levin @cogdog | |
-- https://github.com/cogdog/Keynote-Tweet | |
-- This version requires rtweet from @kearneymw | |
-- https://rtweet.info/index.html | |
set dialogResult to display dialog ¬ | |
"Version 1.0 by @dkiesow... Would you like to add any text (e.g. #hashtags or @usernames) to all of your tweets?" with title ¬ | |
"Keynote-rTweet" with icon note ¬ | |
default answer ¬ | |
"" buttons {"None", "Add This Text"} ¬ | |
default button "Add This Text" | |
if button returned of dialogResult is "None" then | |
set extras to "" | |
else | |
set extras to text returned of dialogResult | |
end if | |
set lastTweet to "" | |
display dialog ¬ | |
"The app will tweet everything between the [twitter][/twitter] tags in your presenter notes when you advance pages in Keynote. For your first tweet - put [first] after the closing [/twitter] Use the menu to quit this script when you're finished." with title ¬ | |
"Keynote TweetR" with icon caution ¬ | |
buttons {"Begin"} ¬ | |
default button "Begin" | |
on idle | |
tell application "System Events" | |
set okflag to (exists (some process whose name is "Keynote")) | |
end tell | |
if okflag then | |
tell application "Keynote" | |
if playing is true then | |
set slideNotes to get presenter notes of current slide of first document | |
if slideNotes is not equal to "" then | |
set leftCoord to offset of "[twitter]" in slideNotes | |
set rightCoord to offset of "[/twitter]" in slideNotes | |
set first_check to offset of "[first]" in slideNotes | |
log first_check | |
if first_check is greater than 0 then | |
set firstTweet to "yes" | |
log firstTweet | |
else | |
set firstTweet to "no" | |
log firstTweet | |
end if | |
if leftCoord is greater than 0 and rightCoord is greater than 0 then | |
set tweet to get characters (leftCoord + 9) thru (rightCoord - 1) of slideNotes as string | |
if tweet is not equal to "" then | |
if extras is not equal to "" then set tweet to tweet & " " & extras | |
if tweet is not equal to lastTweet then | |
set twitter_status to quoted form of (tweet) | |
-- Replace the below with the appropriate paths for your system (rscript path and then the path to your R script) | |
do shell script "/usr/local/bin/rscript /Users/kiesowd/keynote_tweet/keynote.R " & twitter_status & " " & firstTweet | |
log twitter_status | |
log firstTweet | |
set lastTweet to tweet | |
end if | |
end if | |
end if | |
end if | |
end if | |
return 1 | |
end tell | |
end if | |
end idle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment