twitter2jabber 0.2.2 → 0.2.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/TODO +6 -2
- data/lib/twitter2jabber/version.rb +1 -1
- data/lib/twitter2jabber.rb +33 -14
- metadata +2 -2
data/README
CHANGED
data/TODO
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
- some kind of bookmark/remember/read later command
|
1
2
|
- threading? (decouple Twitter and Jabber event loops)
|
2
|
-
-
|
3
|
+
- use streaming API? (http://apiwiki.twitter.com/Streaming-API-Documentation)
|
4
|
+
- explicit retweet (http://apiwiki.twitter.com/Twitter-REST-API-Method:-statuses-retweet)
|
3
5
|
- persistent cache? (friends_timeline: since/since_id?)
|
4
6
|
- OAuth (register: http://twitter.com/oauth_clients/new)
|
5
7
|
- better interrupt handling (in loop mode)
|
6
8
|
- daemonize after asking for credentials (in loop mode)
|
7
|
-
- additional commands?
|
9
|
+
- additional commands? (full twitter API?)
|
10
|
+
- refactor command handling!
|
8
11
|
- SPECS!!!
|
12
|
+
- DOCS!!
|
data/lib/twitter2jabber.rb
CHANGED
@@ -243,23 +243,24 @@ class Twitter2Jabber
|
|
243
243
|
|
244
244
|
def handle_command(body, from, execute = true)
|
245
245
|
case body
|
246
|
-
when /\
|
246
|
+
when /\A(?:he?(?:lp)?|\?)\z/i
|
247
247
|
deliver(from, <<-HELP) if execute
|
248
|
-
h[e[lp]]
|
248
|
+
h[e[lp]]|? -- Print this help
|
249
249
|
|
250
|
-
de[bug]
|
251
|
-
de[bug] on|off
|
250
|
+
de[bug] -- Print debug mode
|
251
|
+
de[bug] on|off -- Turn debug mode on/off
|
252
252
|
|
253
|
-
bl[ock]
|
254
|
-
fa[v[orite]] #ID
|
253
|
+
bl[ock] @USER -- Block USER
|
254
|
+
fa[v[orite]] #ID -- Add ID to favorites
|
255
255
|
|
256
|
-
rt|retweet #ID
|
257
|
-
re[ply] #ID
|
256
|
+
rt|retweet #ID [!] [STATUS] -- Retweet ID
|
257
|
+
re[ply] #ID [!] STATUS -- Reply to ID
|
258
|
+
d[m]|direct[_message] @USER [!] STATUS -- Send direct message to USER
|
258
259
|
|
259
|
-
le[n[gth]] STATUS
|
260
|
-
[!] STATUS
|
260
|
+
le[n[gth]] STATUS -- Determine length
|
261
|
+
[!] STATUS -- Update status
|
261
262
|
|
262
|
-
(Note:
|
263
|
+
(Note: STATUS must be under #{MAX_LENGTH} characters; force send with '!'.)
|
263
264
|
HELP
|
264
265
|
when /\Ade(?:bug)?(?:\s+(on|off))?\z/i
|
265
266
|
if execute
|
@@ -274,7 +275,7 @@ le[n[gth]] STATUS -- Determine length
|
|
274
275
|
|
275
276
|
deliver(from, "DEBUG = #{debug ? 'on' : 'off'}")
|
276
277
|
end
|
277
|
-
when /\Abl(?:ock)?\s
|
278
|
+
when /\Abl(?:ock)?\s+[@#]?(\w+)\z/i
|
278
279
|
twitter.block($1) if execute && !debug
|
279
280
|
when /\Afav?(?:orite)?\s+#?(\d+)\z/i
|
280
281
|
twitter.favorite_create($1) if execute && !debug
|
@@ -293,10 +294,11 @@ le[n[gth]] STATUS -- Determine length
|
|
293
294
|
end
|
294
295
|
|
295
296
|
begin
|
296
|
-
if body.sub!(/\A(?:rt|retweet)
|
297
|
+
if body.sub!(/\A(?:rt|retweet)\s+#?(\d+)(:?)(?:\s+|\z)/i, '')
|
297
298
|
id, colon = $1, $2
|
298
299
|
|
299
300
|
tweet = twitter.status(id)
|
301
|
+
raise Twitter::NotFound unless tweet.is_a?(Mash)
|
300
302
|
|
301
303
|
body << ' ' unless body.empty?
|
302
304
|
body << "RT @#{tweet.user.screen_name}#{colon} #{tweet.text}"
|
@@ -304,6 +306,7 @@ le[n[gth]] STATUS -- Determine length
|
|
304
306
|
id, colon = $1, $2
|
305
307
|
|
306
308
|
tweet = twitter.status(id)
|
309
|
+
raise Twitter::NotFound unless tweet.is_a?(Mash)
|
307
310
|
|
308
311
|
body.insert(0, ' ') unless body.empty?
|
309
312
|
body.insert(0, "@#{tweet.user.screen_name}#{colon}")
|
@@ -315,6 +318,11 @@ le[n[gth]] STATUS -- Determine length
|
|
315
318
|
return
|
316
319
|
end
|
317
320
|
|
321
|
+
if body.sub!(/\A(?:dm?|direct(?:_message)?)\s+[@#]?(\w+):?\s+/i, '')
|
322
|
+
options[:user] = $1
|
323
|
+
dm = true
|
324
|
+
end
|
325
|
+
|
318
326
|
if body.sub!(/\A!(?:\s+|\z)/, '')
|
319
327
|
force = true
|
320
328
|
end
|
@@ -326,7 +334,18 @@ le[n[gth]] STATUS -- Determine length
|
|
326
334
|
return body unless execute
|
327
335
|
|
328
336
|
if force || body.length <= MAX_LENGTH
|
329
|
-
|
337
|
+
if dm
|
338
|
+
user = options[:user]
|
339
|
+
|
340
|
+
if debug
|
341
|
+
logt "DM: #{body} (#{options.inspect})", true
|
342
|
+
else
|
343
|
+
twitter.direct_message_create(user, body)
|
344
|
+
end
|
345
|
+
else
|
346
|
+
update(body, options)
|
347
|
+
end
|
348
|
+
|
330
349
|
deliver(from, "MSG SENT: #{body.inspect}, #{options.inspect}")
|
331
350
|
else
|
332
351
|
deliver(from, "MSG TOO LONG (> #{MAX_LENGTH}): #{body.inspect}")
|
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.2.
|
4
|
+
version: 0.2.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-
|
12
|
+
date: 2009-10-24 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|