Hacker News new | past | comments | ask | show | jobs | submit login
T – a command-line power tool for Twitter (sferik.github.io)
185 points by lelf on Sept 29, 2014 | hide | past | favorite | 49 comments



At WPI, in 1989, we had 's'- a command line tool (written in ksh!) to send a message to someone or to your friends logged in. You had a .friends file and a .enemies file (to blacklist people from contacting you). We also had "superwho" which gave a graphical map (vt220 graphics) of where everyone was.

Now 25 years later we finally have 'T'! Progress..


By 1998 (when I was there), I don't remember ever seeing anything like that (we used normal Unix 'talk' to communicate with people logged into the Digital Unix servers).

Go Engineers!


There was a burst of hacking because of the final transition to UNIX. I was privileged to experience the much more diverse before time: A DECSYSTEM-20 was the main campus computer (it used a Z-80/S100 bus custom terminal multiplexer), the OS course involved writing an OS in PDP-11/23 assembly language, you could write your documents using the Wang word processing computer, of course there were VAXen and there was even an IBM mainframe. There were some UNIX machines (3B2s..), but everything changed when the DEC-20 was replaced with an Encore Multimax and Decstation-2100s (I remember "xtank" was a popular multiplayer game on them).

I could see the vestiges of the previous burst of hacking in the DEC-20's student written software library.

The popularity of the messaging programs should have been a big hint to us..


> a Z-80/S100 bus

What used to be the heart of a microcomputer.

A Serious Business Micro, that is, not a glorified game system like a Commodore-64.

> xtank

There's documentation of a work to port it to modern systems:

http://documentation.wikia.com/wiki/Xtank

Also something on Freecode:

http://freecode.com/projects/xtank


It sounds awesome but I was there in 1990 and worked in the computer lab and never saw it.


DEC-20 was retired in 1988 I think. Also this was when the computer lab (WACCC) was in the library- before it moved to the CS building.


Also, the hackers were big users of the the wpi.* USENET groups (which were a replacement of the TOPS-20 MM groups- actually one of the first student written UNIX programs was 'bboard'- because they didn't have news installed on the Encore at first).


One of my favorite tools...in fact, I'd argue that T is what got me to finally understand why, as a programmer, I should still care about CLI (sferik maintains both T and the excellent Ruby twitter client gem, which powers T)...Studying the T code has also helped me understand the principles of a good CLI system...all around, a well-maintained and fun project.

Using the `--csv` flag and a command-line tool like csvkit, you can make all sorts of utilities. Here's how to unfollow everyone who doesn't follow you:

       t leaders --csv | csvcut -c 9 | xargs t unfollow
Unfollowing everyone who hasn't tweeted since the first half of 2013:

       t followings --csv | csvgrep -c 3 -r '2013-0[1-6]' | csvcut -c 9 | xargs t unfollow

Note: I haven't run these in awhile so the field order may have changed...


Looking at some of the examples the csv part is unneeded in the first example.

t leaders | xargs t unfollow #will work


Oops, you're right. That was a vestigial step for when I was filtering the list by some standard (e.g. less/greater than certain number of followers) and then unfollowing.


better to use --long instead of --csv, the latter preserves newlines that can lead to problems with piping and xargs.


Favorite T hack:

  t followers --sort=since > followers.log
Keep followers.log checked into Git and track your followers/unfollowers over time.


I have the following project for this. https://github.com/ahmetalpbalkan/goodbye It can DM you when someone unfollows you. But you need to host it somewhere.


tempting, but i feel that tracking who unfollows me would only annoy me for no good reason.


No need to use git, since you can just use diff(1) to find the unfollowers between any two dates. I've been doing this for a while with a Go program I created[0].

Unfortunately, people who change their Twitter handles (which I found surprisingly common) show up as false positives - you either need to filter these out manually or match against the user id[1].

[0] https://github.com/ChimeraCoder/twitter-follower-logger

[1] Adding that as a separate field and then calling `cut -f2` would be a quick hack, now that I think about it.


True, but git comes with many tools (e.g. gitk) that make it really easy to the diffs-over-time of a repo.


I made a thing yesterday to do just that. :)

https://github.com/ryanseys/twidiff


That's a nice simple little script. Thanks for sharing!


that is a really great idea


Thanks!


Usually this would be banned because it acts as a Twitter client and doesn't show the ads. In this case you have to sign up for your own app ID, though, so it will just be banned piece by piece as the Twitter API enforcement bots catch each instance. I had a lot of apps seemingly auto-killed by Twitter, games that used to use the API to let you Tweet scores easily, mostly, so expect this app will be similarly classified.


There are other rules this is breaking. https://dev.twitter.com/overview/terms/rules-of-the-road

You must:

4. not arrange for your Service to be pre-installed on any device, promoted as a “zero-rated” service, or marketed as part of a specialized data plan.

5. not frame or otherwise reproduce significant portions of the Twitter service. You should display Twitter Content from the Twitter API.


4. Where is this preinstalled anywhere?

5. This isn't a full blown Twitter client, just a CLI interface. There's a difference.


Whoops, got the wrong numbers. (The numbers don't copy-and-paste with the text). I meant: 5. display a prominent link or button in your Service that directs new users to Twitter’s sign-up functionality.


I thought the API didn't have ads? That is why all 3rd party clients are twitter ad-free.


This is another one I've used, with a somewhat different set of functionality: http://www.floodgap.com/software/ttytter/


I really liked ttytter. I got to where I preferred it over any graphical clients – the information density was so much higher in the console. Sadly it has not been updated in a while (and I have since left twitter).


Does anyone else remember micq, a command line ICQ client? It was such a beaut.


Indeed! I used micq for several years back in the late 90's.


Been using this for a while in a cron job to automate archiving tweets for various topics I'm interested in https://github.com/stephenturner/twitterchive



Sadly, got (a go clone of T by the same author) isn't far along: https://github.com/sferik/got


Are there any command line twitter clients that allow the posting of images? ttytter can't do it, and it seems this "t" can't either.


Actually you can, see:

https://github.com/sferik/t/blob/7f1fcac61047dcb703e9519c837...

this is because the OP's own twitter ruby gem can do that, this CLI app is basically a front end for the ruby gem

    client.update_with_media("I'm tweeting with @gem!", File.new("/path/to/media.png"))
https://github.com/sferik/twitter/blob/48efb642beaa19355a4c1...


Well here's the essential bits in Python. I leave turning this into an actual CLI as an exercise for the interested reader.

    from requests_oauthlib import OAuth1Session
    import json


    keys = json.loads(open(keyfile).read())
    #  {"TWITTER_CONSUMER_KEY": "blah_blah_blah",
    #   "TWITTER_CONSUMER_SECRET": "blah_blah_blah",
    #   "TWITTER_ACCESS_TOKEN": "blah_blah_blah",
    #   "TWITTER_ACCESS_TOKEN_SECRET": "blah_blah_blah",}


    def twitter():
        return OAuth1Session(keys['TWITTER_CONSUMER_KEY'],
                             client_secret=keys['TWITTER_CONSUMER_SECRET'],
                             resource_owner_key=keys['TWITTER_ACCESS_TOKEN'],
                             resource_owner_secret=keys['TWITTER_ACCESS_TOKEN_SECRET'])


    def tweet(status, reply_to=None):
        endpoint = 'https://api.twitter.com/1.1/statuses/update.json'
        data = {'status': status}
        r = twitter().post(endpoint, data=data)
        return r.status_code


    def tweet_with_image(status, imgfile, reply_to=None):
        endpoint = 'https://api.twitter.com/1.1/statuses/update_with_media.json'
        data = {'status': status}
        if reply_to is not None:
            data.update({'in_reply_to_status_id': reply_to})
        r = twitter().post(endpoint, data=data, files={'media[]': open(imgfile, 'rb').read()})
        return r.status_code


I just skimmed and re-skimmed the usage examples on the page, and I see no option to actually tweet something.

I assume this has to do with the third party limit ?


t update "I'm tweeting from the command line. Isn't that special?"


I don't understand why someone would think that "T" is good name for something like this.


Cool, this will makes it easier to script IOT device to use Twitter as messaging service.


Very cool tool. Does anyone know of a similar one for Facebook?


There's a privacy option to disable 3rd party app access (FB apps used by other people) to personal info so nothing as full featured is possible.


thanks for the reply. I am not looking for all those features. I just want to update status from the command line this way I can use them in my static generator workflow ;-)


I don't know of a generic tool that does this but you could create one in a couple of minutes in your scripting language of choice.

Go here and generate yourself a token for your account: https://developers.facebook.com/tools/explorer

Then do the equivalent of

    curl -X POST -d "message='Your status message goes here.'" https://graph.facebook.com/me/feed?access_token=YOUR_TOKEN_HERE


I cross-post tweets to FB with this app: https://apps.facebook.com/twitter/. I wish it had a way not cross-post everything, i.e. with a #nofb tag, but my volume isn't high enough that that's a concern.


There used to be a nice FB app called Selective Tweets that let you append #fb to tweets you wanted to show up on Facebook, but it doesn't seem to work anymore and seems un-maintained.


The Facebook API is really nice (at least by the standards of such things) - if there isn't one now it should be straightforward to write.


Anyone have a zsh completion file for t?



This is neat. I had no idea it existed. Forever in love with the power & simplicity of Ruby.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: