-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
35 lines (18 loc) · 1.59 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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!