Tweet and deliver10.29.15 · python
In Slack, everyone’s favorite office chat time waster, you can post gifs really easily:
But Twitter, for all it’s memey-ness, makes you upload gifs manually, like it’s 2013 or something. Surely there’s a better way, right?
slashgif is a Python3 Twitter bot that, when mentioned, searches Giphy for an appropriate image and then tweets back at everyone mentioned - like this:
Why is this so cool? Because slashgif is the ultimate Twitter bot starter kit. It handles all of the basics for you:
- Uses Tweepy to access Twitter’s streaming API and listen for any mentions of itself and manages rate limiting
- Knows not to tweet back at itself, or to process RTs
- Converts hashtags into plain text and then turns the entire tweet (minus @mentions) into a search query
- Ensures that the outgoing tweet is no longer than 140 characters
The Giphy portion is straightforward too—it’s like one API call, but you can swap that out for any action you want. Return a song from Spotify, a video from YouTube, or don’t search at all and just RickRoll people on demand.
How am I going to use slashgif? I’m modding it to highlight my favorite Devpost projects with custom generated gif whenever I tweet about them. It’s gonna be sweet.
Now, stop thinking about “wouldn’t it be cool if when I tweeted…” and go build yourself a bot!