tit 1.2.5 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,12 @@
1
+ # tit 2.0.1 2011-08-23
2
+
3
+ * fixed bug with the count
4
+
5
+ # tit 2.0.0 2011-08-18
6
+
7
+ * added direct messaging
8
+ * fixed a whole slew of bugs
9
+
1
10
  # tit 1.2.5 2011-08-18
2
11
 
3
12
  * some freaky fixes that i don't remember
@@ -1,4 +1,4 @@
1
1
  ---
2
- :major: 1
3
- :minor: 2
4
- :patch: 5
2
+ :major: 2
3
+ :minor: 0
4
+ :patch: 1
data/bin/tit CHANGED
@@ -48,6 +48,17 @@ def main
48
48
  options[:payload] ||= {}
49
49
  options[:payload]["status"] = status
50
50
  end
51
+ opts.on("-d", "--dm [USERNAME] [MESSAGE]", "Read direct messages. Send a direct message if USERNAME and MESSAGE are set") do |user, message|
52
+ unchanged = false
53
+ if not user.nil? and not message.nil?
54
+ options[:action] = :new_direct_message
55
+ options[:payload] ||= {}
56
+ options[:payload]["screen_name"] = user
57
+ options[:payload]["text"] = message
58
+ else
59
+ options[:action] = :direct_messages
60
+ end
61
+ end
51
62
  opts.on("--pin PIN", ("Set auth pin if this is your first time playing " +
52
63
  "with this tit")) do |pin|
53
64
  unchanged = false
@@ -97,7 +108,7 @@ def main
97
108
  options[:debug] = true
98
109
  end
99
110
 
100
- opts.on_tail("-c", "--count [NUM_STATUSES]", "Set number of statuses you see") do |count|
111
+ opts.on_tail("-c", "--count [NUM]", "Set number of statuses you see") do |count|
101
112
  unchanged = false
102
113
  tit.update_count(count)
103
114
  end
@@ -146,6 +157,11 @@ def main
146
157
  tit.abort("can't repeatedly update status") unless options[:wait].nil?
147
158
  tit.abort("can't notify when updating status") unless options[:notify].nil?
148
159
  end
160
+ if options[:action] == :new_direct_message
161
+ tit.abort("need message to send a dm") unless options[:payload].include? "message"
162
+ tit.abort("can't repeatedly update status") unless options[:wait].nil?
163
+ tit.abort("can't notify when updating status") unless options[:notify].nil?
164
+ end
149
165
 
150
166
  # do it
151
167
  if options[:debug]
data/lib/tit.rb CHANGED
@@ -91,21 +91,23 @@ end
91
91
  Why are you reading the documentation, you cunt?
92
92
  =end
93
93
  class Tit
94
- VERSION = [1, 2, 4]
94
+ VERSION = [2, 0, 1]
95
95
 
96
96
  RCFILE = File.join(ENV["HOME"], ".titrc")
97
97
  RTFILE = File.join(ENV["HOME"], ".titrt")
98
98
  ATFILE = File.join(ENV["HOME"], ".titat")
99
99
 
100
- READERS = [:public, :home, :mentions, :user_timeline]
101
- WRITERS = [:update]
100
+ READERS = [:public, :home, :mentions, :user_timeline, :direct_messages]
101
+ WRITERS = [:update, :new_direct_message]
102
102
 
103
103
  URLS = {
104
104
  :public => "/statuses/public_timeline.xml",
105
105
  :home => "/statuses/home_timeline.xml",
106
106
  :mentions => "/statuses/mentions.xml",
107
107
  :user_timeline => "/statuses/user_timeline.xml",
108
- :update => "/statuses/update.xml"
108
+ :update => "/statuses/update.xml",
109
+ :direct_messages => "/direct_messages.xml",
110
+ :new_direct_message => "/direct_messages/new.xml"
109
111
  }
110
112
 
111
113
  KEY = "K2OOlWbQodfm4YV9Fmeg"
@@ -216,6 +218,17 @@ class Tit
216
218
 
217
219
  @access_token.post(URLS[:update], payload)
218
220
  end
221
+
222
+ def send_dm(payload)
223
+ if payload["text"].length > 140
224
+ tuts "your message is too long (by #{payload["text"].length - 140} characters)"
225
+ tuts "here is what would get posted:"
226
+ payload["text"][0...140].wrapped(@cols - 2).each { |l| puts " #{l}" }
227
+ exit(-1)
228
+ end
229
+
230
+ @access_token.post(URLS[:new_direct_message], payload)
231
+ end
219
232
 
220
233
  def show_tit(status)
221
234
  person = if status[:userid].eql? @userid
@@ -278,11 +291,14 @@ class Tit
278
291
  end
279
292
  elsif options[:action] == :update
280
293
  update options[:payload]
294
+ elsif options[:action] == :new_direct_message
295
+ send_dm options[:payload]
281
296
  end
282
297
  end
283
298
 
284
299
  def update_count(count)
285
300
  @prefs[:count] = count
301
+ @prefs["count"] = count
286
302
  File.open(RCFILE, "w") do |rc|
287
303
  YAML.dump(@prefs, rc)
288
304
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tit}
8
- s.version = "1.2.5"
8
+ s.version = "2.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Leif Walsh", "Parker Moore"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: tit
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.5
5
+ version: 2.0.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Leif Walsh