blackwinter-twitter2jabber 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +1 -1
- data/lib/twitter2jabber.rb +31 -13
- data/lib/twitter2jabber/version.rb +1 -1
- metadata +3 -4
data/README
CHANGED
data/lib/twitter2jabber.rb
CHANGED
@@ -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
|
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
|
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
|
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
|
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
|
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
|
-
|
283
|
-
|
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
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
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)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blackwinter-twitter2jabber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
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-
|
12
|
+
date: 2009-09-08 00:00:00 -07:00
|
13
13
|
default_executable: twitter2jabber
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -87,7 +87,6 @@ files:
|
|
87
87
|
- sample/templates/tweet.txt
|
88
88
|
has_rdoc: false
|
89
89
|
homepage: http://twitter2jabber.rubyforge.org/
|
90
|
-
licenses:
|
91
90
|
post_install_message:
|
92
91
|
rdoc_options:
|
93
92
|
- --line-numbers
|
@@ -116,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
115
|
requirements: []
|
117
116
|
|
118
117
|
rubyforge_project: twitter2jabber
|
119
|
-
rubygems_version: 1.
|
118
|
+
rubygems_version: 1.2.0
|
120
119
|
signing_key:
|
121
120
|
specification_version: 3
|
122
121
|
summary: Twitter-to-Jabber gateway.
|