Latest tweet (for Twitch/Nightbot)

Allows you to retrieve the latest tweet from an “open” (not locked/protected) Twitter account.

Example URL: – This will display my latest tweet.
This can either be a normal tweet like: “This is a normal tweet”, or a retweet. A retweet will be displayed as: “RT @RetweetedUser: This is a retweet”.

Optional parameters:

This is a list of optional URL parameters that will modify the look of how the tweet is passed back

  • no_rts – Ignores retweets and gets the latest normal tweet.
  • url – Appends the direct URL of the tweet. Looks like this: This is a tweet - URL_HERE
  • howlong – Appends how long it has been since the tweet was tweeted out. Looks like this: This is a tweet - 12 hours, 4 minutes ago

Here’s an example URL with all the parameters specified:

Nightbot command:
If you want to add this as a Nightbot command, you just have to put the command result as: $(customapi URL). Replace URL with the specific URL as I showed in the example.

If you wish to specify the Twitter account to retrieve the tweet from per command-use, then you can add “$(touser)” after “name=”. If you do this, then I recommend limiting it to moderators-only to prevent abuse.

Ankhbot (R2) command:

Ankhbot is similar, but the command result is $readapi(URL). Replace URL with the specific URL as I showed in the example.

Important note:
Private/locked Twitter accounts will give this error: “Not authorized. (Normally this means locked/private account)”.
Invalid usernames will show: “Sorry, that page does not exist.”

And of course, this isn’t required to be used with Nightbot, but there’s not much of a point to use it elsewhere unless you wanna fetch it directly instead of using the Twitter API.

If you found some use out of this, I would recommend my post about custom APIs, which covers this and many more scripts that might be useful to have in your bot.

Latest tweet (for Twitch/Nightbot)