console_tweet 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ module ConsoleTweet
7
7
  require 'yaml'
8
8
 
9
9
  # The allowed API methods
10
- AllowedMethods = [:setup, :help, :status, :tweet, :timeline, :show]
10
+ AllowedMethods = [:setup, :help, :status, :tweet, :timeline, :show, :replies]
11
11
 
12
12
  # Twitter API details
13
13
  ConsumerKey = 'MvVdCyl6xCVtEUVdcp4rw'
@@ -122,6 +122,19 @@ module ConsoleTweet
122
122
  tokens = {:default => { :token => @access_token.token, :secret => @access_token.secret }}
123
123
  save_tokens(tokens)
124
124
  end
125
+
126
+ # Returns the 20 most recent @replies / mentions
127
+ def replies(*args)
128
+ load_default_token
129
+ return failtown("Unauthorized, re-run setup!") unless @client && @client.authorized?
130
+ # Only send since_id_replies to @client if it's not nil
131
+ mentions = since_id_replies ? @client.mentions(:since_id => since_id_replies) : @client.mentions
132
+ if mentions.any?
133
+ print_tweets(mentions)
134
+ # Save the last id as since_id
135
+ self.since_id_replies = mentions.last['id']
136
+ end
137
+ end
125
138
 
126
139
  # Display help section
127
140
  def help(*args)
@@ -130,9 +143,10 @@ module ConsoleTweet
130
143
  puts
131
144
  puts "#{CommandColor}twitter#{DefaultColor} View your timeline, since last view"
132
145
  puts "#{CommandColor}twitter setup#{DefaultColor} Setup your account"
133
- puts "#{CommandColor}twitter status#{DefaultColor} Get your most recent status"
146
+ puts "#{CommandColor}twitter status#{DefaultColor} Get your most recent status"
134
147
  puts "#{CommandColor}twitter tweet \"Hello World\"#{DefaultColor} Send out a tweet"
135
148
  puts "#{CommandColor}twitter show [username]#{DefaultColor} Show the timeline for a user"
149
+ puts "#{CommandColor}twitter replies#{DefaultColor} Get the most recent @replies and mentions"
136
150
  end
137
151
 
138
152
  # Show error message with help below it
@@ -195,6 +209,18 @@ module ConsoleTweet
195
209
  tokens[:since_id] = id
196
210
  save_tokens(:default => tokens)
197
211
  end
212
+
213
+ # Getter for since_id_replies in ~/.twitter file
214
+ def since_id_replies
215
+ load_default_token[:since_id_replies]
216
+ end
217
+
218
+ # Setter for since_id_replies in ~/.twitter file
219
+ def since_id_replies=(id)
220
+ tokens = load_default_token
221
+ tokens[:since_id_replies] = id
222
+ save_tokens(:default => tokens)
223
+ end
198
224
 
199
225
  # Standardized formating of timelines
200
226
  def print_tweets(tweets)
@@ -1,5 +1,5 @@
1
1
  module ConsoleTweet
2
2
 
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: console_tweet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-31 00:00:00.000000000 -04:00
12
+ date: 2011-11-06 01:00:00.000000000 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &70328169435640 !ruby/object:Gem::Requirement
17
+ requirement: &70232062474580 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *70328169435640
25
+ version_requirements: *70232062474580
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: twitter_oauth
28
- requirement: &70328169435120 !ruby/object:Gem::Requirement
28
+ requirement: &70232062474060 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70328169435120
36
+ version_requirements: *70232062474060
37
37
  description: CLI Twitter Client - with OAuth
38
38
  email: john@crepezzi.com
39
39
  executables: