twitter2jabber 0.2.6 → 0.3.0
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 +3 -2
- data/bin/twitter2jabber +26 -18
- data/lib/twitter2jabber/version.rb +2 -2
- data/lib/twitter2jabber.rb +7 -3
- data/sample/config.yaml +6 -4
- metadata +22 -13
data/README
CHANGED
data/TODO
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
- include_entities=true (http://dev.twitter.com/pages/tweet_entities)
|
|
2
|
+
- include_rts=true (?)
|
|
3
|
+
- daemon control script (twitter2jabber-ctl)
|
|
1
4
|
- threading? (decouple Twitter and Jabber event loops)
|
|
2
5
|
- use streaming API? (http://apiwiki.twitter.com/Streaming-API-Documentation)
|
|
3
|
-
- explicit retweet (http://apiwiki.twitter.com/Twitter-REST-API-Method:-statuses-retweet)
|
|
4
6
|
- persistent cache? (friends_timeline: since/since_id?)
|
|
5
|
-
- OAuth (register: http://twitter.com/oauth_clients/new)
|
|
6
7
|
- better interrupt handling (in loop mode)
|
|
7
8
|
- daemonize after asking for credentials (in loop mode)
|
|
8
9
|
- additional commands? (full twitter API?)
|
data/bin/twitter2jabber
CHANGED
|
@@ -48,19 +48,20 @@ rescue Interrupt
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
options = {
|
|
51
|
-
:config
|
|
52
|
-
:
|
|
53
|
-
:
|
|
54
|
-
:
|
|
55
|
-
:
|
|
56
|
-
:
|
|
57
|
-
:
|
|
58
|
-
:
|
|
59
|
-
:
|
|
60
|
-
:
|
|
61
|
-
:
|
|
62
|
-
:
|
|
63
|
-
:
|
|
51
|
+
:config => 'config.yaml',
|
|
52
|
+
:consumer_token => nil,
|
|
53
|
+
:access_token => nil,
|
|
54
|
+
:jid => nil,
|
|
55
|
+
:recipients => [],
|
|
56
|
+
:formats => nil,
|
|
57
|
+
:template_dir => nil,
|
|
58
|
+
:loop => false,
|
|
59
|
+
:pause => nil,
|
|
60
|
+
:last => nil,
|
|
61
|
+
:wrap => nil,
|
|
62
|
+
:log => STDERR,
|
|
63
|
+
:verbose => false,
|
|
64
|
+
:debug => false
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
OptionParser.new { |opts|
|
|
@@ -75,8 +76,12 @@ OptionParser.new { |opts|
|
|
|
75
76
|
|
|
76
77
|
opts.separator ' '
|
|
77
78
|
|
|
78
|
-
opts.on('-
|
|
79
|
-
options[:
|
|
79
|
+
opts.on('-C', '--consumer-token TOKEN', 'Twitter consumer token') { |t|
|
|
80
|
+
options[:consumer_token] = t
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
opts.on('-A', '--access-token TOKEN', 'Twitter access token') { |t|
|
|
84
|
+
options[:access_token] = t
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
opts.on('-j', '--jid ID', 'Jabber ID') { |j|
|
|
@@ -157,9 +162,12 @@ end
|
|
|
157
162
|
|
|
158
163
|
# twitter config
|
|
159
164
|
config[:twitter] ||= {}
|
|
160
|
-
config[:twitter][:
|
|
161
|
-
config[:twitter][:
|
|
162
|
-
config[:twitter][:
|
|
165
|
+
config[:twitter][:consumer_token] = options[:consumer_token] if options[:consumer_token]
|
|
166
|
+
config[:twitter][:consumer_token] ||= ask('Twitter consumer token: ')
|
|
167
|
+
config[:twitter][:consumer_secret] ||= ask("Consumer secret for Twitter application #{config[:twitter][:consumer_token]}: ") { |q| q.echo = false }
|
|
168
|
+
config[:twitter][:access_token] = options[:access_token] if options[:access_token]
|
|
169
|
+
config[:twitter][:access_token] ||= ask('Twitter access token: ')
|
|
170
|
+
config[:twitter][:access_secret] ||= ask("Access secret for Twitter user #{config[:twitter][:access_token]}: ") { |q| q.echo = false }
|
|
163
171
|
|
|
164
172
|
# jabber config
|
|
165
173
|
config[:jabber] ||= {}
|
data/lib/twitter2jabber.rb
CHANGED
|
@@ -64,7 +64,7 @@ class Twitter2Jabber
|
|
|
64
64
|
raise ArgumentError, "#{client} config missing" unless options[client].is_a?(Hash)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
@id = "#{options[:twitter][:
|
|
67
|
+
@id = "#{options[:twitter][:consumer_token]} -> #{options[:jabber][:user]}"
|
|
68
68
|
|
|
69
69
|
@verbose = options[:verbose]
|
|
70
70
|
@debug = options[:debug]
|
|
@@ -157,7 +157,9 @@ class Twitter2Jabber
|
|
|
157
157
|
private
|
|
158
158
|
|
|
159
159
|
def twitter_connect(options)
|
|
160
|
-
auth = Twitter::
|
|
160
|
+
auth = Twitter::OAuth.new(options[:consumer_token], options[:consumer_secret])
|
|
161
|
+
auth.authorize_from_access(options[:access_token], options[:access_secret])
|
|
162
|
+
|
|
161
163
|
client = Twitter::Base.new(auth)
|
|
162
164
|
|
|
163
165
|
# verify credentials
|
|
@@ -167,7 +169,7 @@ class Twitter2Jabber
|
|
|
167
169
|
|
|
168
170
|
client
|
|
169
171
|
rescue Twitter::TwitterError => err
|
|
170
|
-
raise "Can't connect to Twitter with ID '#{options[:
|
|
172
|
+
raise "Can't connect to Twitter with ID '#{options[:consumer_token]}': #{err}"
|
|
171
173
|
end
|
|
172
174
|
|
|
173
175
|
def jabber_connect(options)
|
|
@@ -387,6 +389,8 @@ le[n[gth]] STATUS -- Determine length
|
|
|
387
389
|
end
|
|
388
390
|
|
|
389
391
|
jabber.deliver(recipient, msg)
|
|
392
|
+
rescue => err
|
|
393
|
+
warn "#{err} (#{err.class})"
|
|
390
394
|
end
|
|
391
395
|
|
|
392
396
|
def update(msg, options = {})
|
data/sample/config.yaml
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
:twitter:
|
|
3
|
-
:
|
|
4
|
-
:
|
|
3
|
+
:consumer_token: c5ff16bd638c9acc6fb00197301008c5eb561f46
|
|
4
|
+
:consumer_secret: ae2ad9454f3af7fcb18c83969f99b20a788eddd1
|
|
5
|
+
:access_token: f1b640bee7b738e8f18758990a61c07a17eab637
|
|
6
|
+
:access_secret: 06c76739e3f4875a27a9e3ce36999e1af916a0e0
|
|
5
7
|
|
|
6
8
|
:jabber:
|
|
7
|
-
:user:
|
|
8
|
-
:pass:
|
|
9
|
+
:user: foo
|
|
10
|
+
:pass: foo
|
|
9
11
|
|
|
10
12
|
:recipients:
|
|
11
13
|
- one
|
metadata
CHANGED
|
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
|
4
4
|
prerelease: false
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
version: 0.
|
|
7
|
+
- 3
|
|
8
|
+
- 0
|
|
9
|
+
version: 0.3.0
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Jens Wille
|
|
@@ -14,13 +14,14 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-
|
|
17
|
+
date: 2010-08-14 00:00:00 +02:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: twitter
|
|
22
22
|
prerelease: false
|
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
|
24
|
+
none: false
|
|
24
25
|
requirements:
|
|
25
26
|
- - ">="
|
|
26
27
|
- !ruby/object:Gem::Version
|
|
@@ -33,6 +34,7 @@ dependencies:
|
|
|
33
34
|
name: xmpp4r-simple
|
|
34
35
|
prerelease: false
|
|
35
36
|
requirement: &id002 !ruby/object:Gem::Requirement
|
|
37
|
+
none: false
|
|
36
38
|
requirements:
|
|
37
39
|
- - ">="
|
|
38
40
|
- !ruby/object:Gem::Version
|
|
@@ -45,6 +47,7 @@ dependencies:
|
|
|
45
47
|
name: shorturl
|
|
46
48
|
prerelease: false
|
|
47
49
|
requirement: &id003 !ruby/object:Gem::Requirement
|
|
50
|
+
none: false
|
|
48
51
|
requirements:
|
|
49
52
|
- - ">="
|
|
50
53
|
- !ruby/object:Gem::Version
|
|
@@ -57,6 +60,7 @@ dependencies:
|
|
|
57
60
|
name: longurl
|
|
58
61
|
prerelease: false
|
|
59
62
|
requirement: &id004 !ruby/object:Gem::Requirement
|
|
63
|
+
none: false
|
|
60
64
|
requirements:
|
|
61
65
|
- - ">="
|
|
62
66
|
- !ruby/object:Gem::Version
|
|
@@ -69,6 +73,7 @@ dependencies:
|
|
|
69
73
|
name: highline
|
|
70
74
|
prerelease: false
|
|
71
75
|
requirement: &id005 !ruby/object:Gem::Requirement
|
|
76
|
+
none: false
|
|
72
77
|
requirements:
|
|
73
78
|
- - ">="
|
|
74
79
|
- !ruby/object:Gem::Version
|
|
@@ -81,6 +86,7 @@ dependencies:
|
|
|
81
86
|
name: elif
|
|
82
87
|
prerelease: false
|
|
83
88
|
requirement: &id006 !ruby/object:Gem::Requirement
|
|
89
|
+
none: false
|
|
84
90
|
requirements:
|
|
85
91
|
- - ">="
|
|
86
92
|
- !ruby/object:Gem::Version
|
|
@@ -93,6 +99,7 @@ dependencies:
|
|
|
93
99
|
name: ruby-nuggets
|
|
94
100
|
prerelease: false
|
|
95
101
|
requirement: &id007 !ruby/object:Gem::Requirement
|
|
102
|
+
none: false
|
|
96
103
|
requirements:
|
|
97
104
|
- - ">="
|
|
98
105
|
- !ruby/object:Gem::Version
|
|
@@ -115,32 +122,33 @@ files:
|
|
|
115
122
|
- lib/twitter2jabber.rb
|
|
116
123
|
- lib/twitter2jabber/version.rb
|
|
117
124
|
- bin/twitter2jabber
|
|
125
|
+
- COPYING
|
|
126
|
+
- Rakefile
|
|
118
127
|
- README
|
|
119
128
|
- ChangeLog
|
|
120
|
-
- Rakefile
|
|
121
129
|
- TODO
|
|
122
|
-
- COPYING
|
|
123
|
-
- sample/templates/tweet.txt
|
|
124
|
-
- sample/templates/tweet.html
|
|
125
130
|
- sample/config.yaml
|
|
131
|
+
- sample/templates/tweet.html
|
|
132
|
+
- sample/templates/tweet.txt
|
|
126
133
|
has_rdoc: true
|
|
127
134
|
homepage: http://twitter2jabber.rubyforge.org/
|
|
128
135
|
licenses: []
|
|
129
136
|
|
|
130
137
|
post_install_message:
|
|
131
138
|
rdoc_options:
|
|
139
|
+
- --line-numbers
|
|
140
|
+
- --inline-source
|
|
132
141
|
- --charset
|
|
133
142
|
- UTF-8
|
|
134
|
-
- --title
|
|
135
|
-
- twitter2jabber Application documentation
|
|
136
143
|
- --main
|
|
137
144
|
- README
|
|
138
|
-
- --
|
|
139
|
-
-
|
|
145
|
+
- --title
|
|
146
|
+
- twitter2jabber Application documentation
|
|
140
147
|
- --all
|
|
141
148
|
require_paths:
|
|
142
149
|
- lib
|
|
143
150
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
|
+
none: false
|
|
144
152
|
requirements:
|
|
145
153
|
- - ">="
|
|
146
154
|
- !ruby/object:Gem::Version
|
|
@@ -148,6 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
148
156
|
- 0
|
|
149
157
|
version: "0"
|
|
150
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
|
+
none: false
|
|
151
160
|
requirements:
|
|
152
161
|
- - ">="
|
|
153
162
|
- !ruby/object:Gem::Version
|
|
@@ -157,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
157
166
|
requirements: []
|
|
158
167
|
|
|
159
168
|
rubyforge_project: twitter2jabber
|
|
160
|
-
rubygems_version: 1.3.
|
|
169
|
+
rubygems_version: 1.3.7
|
|
161
170
|
signing_key:
|
|
162
171
|
specification_version: 3
|
|
163
172
|
summary: Twitter-to-Jabber gateway.
|