Skip to content

Instantly share code, notes, and snippets.

@PeterBerthelsen
Created January 21, 2019 17:13
Show Gist options
  • Save PeterBerthelsen/2b1661f8ffe9ae02e7977d91332c29a4 to your computer and use it in GitHub Desktop.
Save PeterBerthelsen/2b1661f8ffe9ae02e7977d91332c29a4 to your computer and use it in GitHub Desktop.
OrthoThread Tweets
//////////////////////////Output///////////////////////////////////////////////////////////
if (r) {
var replyTo = r
} else {
var replyTo = 0; //set reply (each tweet will reply to previous, first will be null
}
for (i in tweets){ //for each tweet in thread...
console.log("Tweet Attempt: " + i); //log attempt number (starting @ 0)
try{
if (imgs[i]) { //if valid image URL exists...
url = imgs[i].toString(); //set URL variable for tweet function
console.log("imgs[" + i + "]: " + imgs[i]); //log image
} else {
url = null;
console.log("imgs[" + i + "]: " + imgs[i]);
}
} catch (e) {
url = null; //null variable for tweet function
console.log("imgs[" + i + "] parse error: " + e); //log image error
}
var newTweet = sendTweet(tweets[i], replyTo, url); //set reply value for next tweet as return of tweet function
Utilities.sleep(250); //wait 1/4 second (for return value, to avoid errors)
if (i == 0) { //if first tweet in thread...
var begins = newTweet //set value for first tweet ID
console.log("Thread begins with tweet(ID): " + begins); //log first tweet ID
}
replyTo = newTweet //set replyTo value to response of last tweet
if (replyTo == undefined) { //if no response...
console.log("replyTo undefined! Breaking loop..."); //log undefined response
break; //break thread, do not tweet more
} else { //if response...
console.log("Next Reply To: " + replyTo); //log reply
}
} //end thread tweeting
return begins;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment