twitter2jabber 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to twitter2jabber version 0.1.2
5
+ This documentation refers to twitter2jabber version 0.1.3
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -97,7 +97,7 @@ class Twitter2Jabber
97
97
  i, seen = 1, Hash.new { |h, k| h[k] = true; false }
98
98
 
99
99
  trap(:INT) {
100
- log "#{Time.now} SIGINT received, shutting down..."
100
+ log 'SIGINT received, shutting down...'
101
101
  i = -1
102
102
  }
103
103
 
@@ -109,7 +109,7 @@ class Twitter2Jabber
109
109
  i += 1
110
110
  end
111
111
 
112
- log "#{Time.now} KTHXBYE!"
112
+ log 'KTHXBYE!'
113
113
  end
114
114
 
115
115
  def deliver_tweets(recipients, seen = {}, &block)
@@ -154,7 +154,7 @@ class Twitter2Jabber
154
154
  # verify credentials
155
155
  client.verify_credentials
156
156
 
157
- logt "#{Time.now} connected"
157
+ logt 'connected'
158
158
 
159
159
  client
160
160
  rescue Twitter::TwitterError => err
@@ -164,7 +164,7 @@ class Twitter2Jabber
164
164
  def jabber_connect(options)
165
165
  client = Jabber::Simple.new(options[:user], options[:pass])
166
166
 
167
- logj "#{Time.now} connected"
167
+ logj 'connected'
168
168
 
169
169
  client
170
170
  rescue Jabber::JabberError => err
@@ -172,7 +172,10 @@ class Twitter2Jabber
172
172
  end
173
173
 
174
174
  def get_tweets
175
- twitter.friends_timeline.sort_by { |tweet|
175
+ tweets = twitter.friends_timeline
176
+ raise Twitter::TwitterError unless tweets.is_a?(Array)
177
+
178
+ tweets.sort_by { |tweet|
176
179
  tweet.created_at = Time.parse(tweet.created_at)
177
180
  }
178
181
  rescue Twitter::TwitterError, Timeout::Error
@@ -279,13 +282,27 @@ le[n[gth]] STATUS -- Determine length
279
282
  return
280
283
  end
281
284
 
282
- if body.sub!(/\A(?:rt|retweet)?\s+#?(\d+)(?::?\s+|\z)/i, '')
283
- tweet = twitter.status($1)
285
+ begin
286
+ if body.sub!(/\A(?:rt|retweet)?\s+#?(\d+)(:?)(?:\s+|\z)/i, '')
287
+ id, colon = $1, $2
288
+
289
+ tweet = twitter.status(id)
290
+
291
+ body << ' ' unless body.empty?
292
+ body << "RT @#{tweet.user.screen_name}#{colon} #{tweet.text}"
293
+ elsif body.sub!(/\Are(?:ply)?\s+#?(\d+)(:?)\s+/i, '')
294
+ id, colon = $1, $2
295
+
296
+ tweet = twitter.status(id)
284
297
 
285
- body << ' ' unless body.empty?
286
- body << "RT @#{tweet.user.screen_name}: #{tweet.text}"
287
- elsif body.sub!(/\Are(?:ply)?\s+#?(\d+):?\s+/i, '')
288
- options[:in_reply_to_status_id] = $1
298
+ body.insert(0, ' ') unless body.empty?
299
+ body.insert(0, "@#{tweet.user.screen_name}#{colon}")
300
+
301
+ options[:in_reply_to_status_id] = id
302
+ end
303
+ rescue Twitter::NotFound
304
+ deliver(from, "TWEET NOT FOUND: #{id}")
305
+ return
289
306
  end
290
307
 
291
308
  if body.sub!(/\A!(?:\s+|\z)/, '')
@@ -300,8 +317,9 @@ le[n[gth]] STATUS -- Determine length
300
317
 
301
318
  if force || body.length <= MAX_LENGTH
302
319
  update(body, options)
320
+ deliver(from, "MSG SENT: #{body.inspect}, #{options.inspect}")
303
321
  else
304
- deliver(from, "MSG TOO LONG (> #{MAX_LENGTH}): #{body}")
322
+ deliver(from, "MSG TOO LONG (> #{MAX_LENGTH}): #{body.inspect}")
305
323
  end
306
324
  end
307
325
  end
@@ -325,7 +343,7 @@ le[n[gth]] STATUS -- Determine length
325
343
  end
326
344
 
327
345
  def log(msg, verbose = verbose)
328
- warn "[#{id}] #{msg}" if verbose
346
+ warn "#{Time.now} [#{id}] #{msg}" if verbose
329
347
  end
330
348
 
331
349
  def logt(msg, verbose = verbose)
@@ -4,7 +4,7 @@ class Twitter2Jabber
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 1
7
- TINY = 2
7
+ TINY = 3
8
8
 
9
9
  class << self
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter2jabber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Wille
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-03 00:00:00 +02:00
12
+ date: 2009-09-08 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency