Home > twitter_dsl

twitter_dsl

Twitter_dsl is a project mainly written in Python, it's free.

A simple python-based DSL experiment allowing code to be executed via tweets

IDEA

Here is a proof of concept for a python-based twitter DSL that is adapted for running code via tweets (so the code needs to be short and concise) and have "first-class" access to live twitter data directly in the language via @user and #tag constructs.

You can give the twitter_dsl.py any code via stdin.

EXAMPLES

print @shitmydadsays[0]

Would simply print out the latest tweet from @shitmydadsays.

print next((t for t in #fail if "cat" in t))

Would print out the first #fail tweet also mentioning a cat.

A little more contrived example (I call it The Irony Machine)

t=@hwaara[0]; w=t.split(" "); r=randint(0, len(w)-1); print " ".join(w[:r]+[""%s"" % w[r]]+w[min(r+1,len(@hwaara)):])

This gets my latest tweet, finds a random word and puts quotes around it, making it "ironic" in some random sense.

A TWITTER EXECUTION BOT

One could expand on this idea, making a bot that accepts code and tweets the output. You could even implement a "goto" or "exec" builtin in the language, allowing to execute code in other tweets by id.

If the bot allowed to rememeber a code tweet by a name and allow for input arguments you could then reuse previous code in your new code, allowing code tweets to be used as functions, and eventually evolving into a sort of big repository of code to build upon.

TODO

  • topic needs to be implemented. Need to switch to another twitter API lib with search capabilities (python-twitter doesn't have it).

  • If you're gonna do this online safely, you need a sandboxed environment. For example pypy's: http://codespeak.net/pypy/dist/pypy/doc/sandbox.html

  • Build the bot!

Previous:phpxmlrpc