Skip to content
Browse files

Show last 20 results before starting to stream

  • Loading branch information...
1 parent 8bbeaee commit 52a1c4caa3e5654fb48a4876e6d83538aa395e1c @sferik committed May 1, 2012
Showing with 24 additions and 11 deletions.
  1. +2 −0 Gemfile
  2. +10 −11 README.md
  3. +12 −0 lib/t/stream.rb
View
2 Gemfile
@@ -8,4 +8,6 @@ platforms :mri do
gem 'ruby-prof'
end
+gem 'tweetstream', :path => "../tweetstream"
+
gemspec
View
21 README.md
@@ -46,17 +46,17 @@ The output of which will be structured like this:
gem
thG9EfWoADtIr6NjbL9ON (active)
-**Note**: One account (specifically, the last one you authorized) is marked as
-active. To change the active account use the `set` subcommand, passing either
-just the username, if it's unambiguous, or the username and consumer key pair.
-Something like this:
+**Note**: One of your authorized accounts (specifically, the last one
+authorized) will be set as active. To change the active account, use the `set`
+subcommand, passing either just the username, if it's unambiguous, or the
+username and consumer key pair, like this:
t set active sferik UDfNTpOz5ZDG4a6w7dIWj
Account information is stored in a YAML-formatted file located at `~/.trc`.
**Note**: Anyone with access to this file can masquerade as you on Twitter, so
it's important to keep it secure, just as you would treat your SSH private key.
-For this reason, the file is hidden and has the permission bits set to 0600.
+For this reason, the file is hidden and has the permission bits set to `0600`.
## Usage Examples
Typing `t help` will list all the available commands. You can type `t help
@@ -86,8 +86,7 @@ obviously can't contain any apostrophes.)
**Note**: If the first user does not follow the second, `t` will exit with a
non-zero exit code. This allows you to execute commands conditionally, for
-example, only attempt to send a user a direct message if he are already
-follows you:
+example, send a user a direct message only if he already follows you:
t does_follow @ev && t dm @ev "What's up, bro?"
@@ -103,7 +102,7 @@ follows you:
### List all your lists, in long format
t lists -l
-### List all your friends, ordered by number of followers
+### List all your friends, in long format, ordered by number of followers
t friends -lf
### List all your leaders (people you follow who don't follow you back)
@@ -112,7 +111,7 @@ follows you:
### Unfollow everyone you follow who doesn't follow you back
t leaders | xargs t unfollow
-### Follow roulette: randomly follow someone who follows you (who you don't already follow)
+### Twitter roulette: randomly follow someone who follows you (who you don't already follow)
t disciples | shuf | head -1 | xargs t follow
### Favorite the last 10 tweets that mention you
@@ -121,8 +120,8 @@ follows you:
### Output the last 200 tweets in your timeline to a CSV file
t timeline -n 200 --csv > timeline.csv
-### Start streaming a real-time sample of all Tweets (Control-C to stop)
- t stream all
+### Start streaming your timeline (Control-C to stop)
+ t stream timeline
### Count the number of employees who work for Twitter
t list members twitter team | wc -l
View
12 lib/t/stream.rb
@@ -1,5 +1,7 @@
+require 't/cli'
require 't/printable'
require 't/rcfile'
+require 't/search'
require 'thor'
require 'tweetstream'
@@ -39,6 +41,11 @@ def matrix
desc "search KEYWORD [KEYWORD...]", "Stream Tweets that contain specified keywords, joined with logical ORs (Control-C to stop)"
def search(keyword, *keywords)
keywords.unshift(keyword)
+ client.on_inited do
+ search= T::Search.new
+ search.options = search.options.merge(:reverse => true)
+ search.all(keywords.join(' OR '))
+ end
client.on_timeline_status do |status|
print_status(status)
end
@@ -51,6 +58,11 @@ def search(keyword, *keywords)
desc "timeline", "Stream your timeline (Control-C to stop)"
def timeline
+ client.on_inited do
+ cli = T::CLI.new
+ cli.options = cli.options.merge(:reverse => true)
+ cli.timeline
+ end
client.on_timeline_status do |status|
print_status(status)
end

0 comments on commit 52a1c4c

Please sign in to comment.
Something went wrong with that request. Please try again.