5 ms·
A Twitter Bot in One Line of Code
- 10ren 17y agooblig. challenge: twitter bot in 140 chars... BTW: great twitter API, and demo of bash as a JSON webservice server implementation language. It repays careful study. Also "bash" has got to be the best name for a hacker's language.
- InclinedPlane 17y agoIn APL that just might be possible.
- amalcon 17y agoFor bonus points, make a twitter-quine: as some part of its operation, have the bot tweet its own source code.
- tesseract 17y agocurl -F"status=$BASH_COMMAND" -utq_:pass12 -HExpect: 'http://twitter.com/statuses/update.xml'
- iuguy 17y agoI've tried, but the lowest I could get is around the 230-240 mark for something that tweets hi $n (where $n is the name of the person tweeting something you're interested in) for bash. It seems the URLs are the killer. URL Shorteners would help but bleh security. Any ideas for different languages?
- idm 17y agoHere's what I have so far: o=onelinebot;u=$o:one.$o;t=twitter.com;h=http://;alias http://;alias a=alias;a w=while\ read;a c="curl -u$u -d";c track=$o ${h}stream.$t/track.json>t&tail -f t|w t;do echo $t|grep -Eo '"screen_name":"[[:alnum:]]+"'|cut -d\" -f4|w s;do c '' $h$t/friendships/create/$s.json?follow=true;done;done It's two tweets (280 chars, down from 417) and it's not quite functional... This one will track "onelinebot" instead of "one line." It's basically the same as the original post, but with lots of nasty substitutions. I figured I'd share, because I really need to get back to some other work - if you can get it working, please share.
- dominiek 17y agoNice!
- noodle 17y agoif the only qualifier for "one line" is that its a big chunk of code with no line breaks, i think i could do more than just a twitter bot on one line.
- jsteele 17y agoI've also seen too many blog posts trumpeting the amazing ability to do something-or-other in three lines of Ruby -- one or two of which are loading some library that does all the work. Not impressed. It's nice that you can get something done with minimal work, but the emphasis should be on ease of use, not on number of lines.
- deleted 17y ago[deleted]
- deleted 17y ago[deleted]
- peterwwillis 17y agoObligatory perl example, pretty messy: U="onelinebot:one.onelinebot";curl -d 'track=obama' http://stream.twitter.com/track.json http://stream.twitter.com/track.json -u$U|perl -ne'/\"screen_name\":\"([^"]+)\"/&&`curl -d "" http://twitter.com/friendships/create/$1.json?follow=true http://twitter.com/friendships/create/$1.json?follow=true -u$U`'
- tzury 17y agoGive me a break. Once you put ';' it cannot be consider as one line, otherwise, minified-jQuery is also a one line library. http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.j...
- jrockway 17y ago"one line" -- the most meaningless software metric to date.