Twitter | GitHub
Give me DALL-E access pls


I've decided to get serious about Twitter bots

So I've decided to farm dopamine by creating Twitter bots. I use Twitter as a platform to just yeet text into the void, and writing some code to yeet text for me is a great shortcut to dopamine. Huge shoutout to @JanelleCShane at aiweirdness.com for basically kicking off my addiction to the chaos of giving an imperfect AI weird text prompts.

If I'm going to be "a ______ guy", I might as well become a Twitter bot guy.

Why Twitter?

Twitter solves a handful of problems that I've had with my personal projects

  1. The things I like to make require some user interaction. Twitter is great for just having an endless feed of unwitting participants.
  2. It's relatively easy to get people to see your project. People are really reluctant to click on a link to " mycoolproject.com" for many (valid) reasons, but they will be forced to look at your tweet when you post or retweet it.

Also, Twitter is already home to some really amazing bots, take a look:

Anyways, here is a list of things "Do"s and "Do Not"s I've learned from making some Twitter bots:

Make things for yourself

Don't count on a silly little side project to become "a thing", even though you think its the greatest idea ever. You should be working on coding projects for two reasons:

  1. Its fun. 3 years after making ThisRecipeDoesNotExist, it still makes me laugh on a daily basis, even though only a handful of people have ever seen it.

  2. Resume filler. Fill up that Github page with some keyword spam and prove to HR that you know what a variable is. Writing a Twitter bot is proof that you know at least a little bit about APIs and authentication while also having a tangible thing that an employer can see and use.

I find the idea of an AI generating some dumb tweets is the coolest thing ever, so I just do it.

Don't use infinite loops to post things on a schedule

While it's pretty tempting to just do something like this

while True:

Its going to inevitably break when you hit a rate limit or some other state that throws an error. Also, depending on the latency of the API you're hitting, your bot isn't going to end up posting every minute. Use AWS Lambda functions with a CloudWatch event to schedule some script to run on a schedule instead.

Don't use infinite loops to check for new notifications

If the API of the platform you're using supports them, use webhooks to get notified when your bot account gets new notifications. I'm 100% guilty of writng code that looks like:

while True:
    notifications = twitter.get_notifications()
    for notification in notifications:

This works perfectly fine, but youre going to be hitting the API over and over again, all day every day, even if you're getting no notifications.

Heavily rely on other people's code

I feel like a lot of people (me included sometimes) have this idea that you aren't actually programming. And thats dumb.

There is no shame in just duct taping together a bunch of external libraries or writing some quick and dirty code to pass data from one API to another. The current iteration of @DoesRecipe can basically be boiled down to a few lines of pseudo-code:

mentions = twitter.GetMentions()
for mention in mentions:
    response = openai.Completion.create(prompt=f"{mention.body} Recipe:")
    twitter.post(response.choices.text, in_reply_to_status_id=mention.id)

sure, if I wanted to, I could spend a day fiddling with twitter oauth2 code and finding the specific version of Cuda that will let my graphics card magically run some Tensoflow code, but I don't want to do that. Its totally worth it to just piggyback off of someone else's API wrapper or throw a few pennies at OpenAI.

Don't keep working on the same project forever

Its hard for a programmer to be comfortable with calling a project "done", but once you have a good thing going and progress starts to slow down, just stop. Take your mental checklist of things to add to your project and apply them to your next one. You do enough work for your real job, personal projects shouldn't burn you out.

The footer is actually pretty cool