flypig.co.uk

QuineTwt

QuineTwt is a Twitter Quine, a program that tweets itself. Here's the code for it:

#@quinetwt
import twitter as T;x='chr(35)+"@quinetwt"+chr(10)+"import twitter as T;x="+chr(39)+x+chr(39)+";T.Api("+chr(42)+").PostUpdate("+x+")"';T.Api(*).PostUpdate(chr(35)+"@quinetwt"+chr(10)+"import twitter as T;x="+chr(39)+x+chr(39)+";T.Api("+chr(42)+").PostUpdate("+x+")")

Honestly. I just spent my entire Sunday writing this code and I'm not sure why. But you should definitely try it for yourself. If you run it, it'll tweet to your account. To get it to work you'll need to replace the * with your developer access tokens. Don't worry, these won't get tweeted.

If you know python this should all be straightforward. If you're not entirely comfortable with all this, below are some more detailed instructions.

The code, including for the @QuineTwt reply bot, can be found on github.

Instructions

To execute the quine you'll need to have a Twitter developer account. If you don't already have one, you can create one by going to developer.twitter.com and filling out the (unfortunately now quite lengthy but otherwise straightforward) application form.

Once you have an account, select Apps followed by Create an app. There you'll be able to fill out yet more formage, after all of which you'll end up with your Consumer API keys and your access tokens. When you're filling out the form be sure to give the quine write access.

Now create a file called quine.py and paste the quine code above into it (or you can copy and paste it from a Tweet like this one). Replace the * with your keys, separated by commas, in this order: consumer_key, consumer_secret, access_token_key, access_token_secret. The end result will look something like this, but with your own much longer keys:

...T.Api('Y6F675','78HF4F','8UFGE4','12F4A0')...

Save the file and now you're ready to execute it.

It's easiest to execute it in a virtual environment. Here's a brief overview of how I'd go about doing that:

# Set up your virtual environment
mkdir venv
cd venv
virtualenv .
source ./bin/activate
pip install python-twitter

# Execute your quine
python ../quine.py

# Deactivate and delete the virtual environment
deactivate
cd ..
rm -rf venv

Enjoy! I'm going to bed.

Comments

Uncover Disqus comments