earthquake 0.5.8 → 0.5.9
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/earthquake.gemspec +1 -1
- data/lib/earthquake/commands.rb +13 -13
- data/lib/earthquake/core.rb +3 -4
- data/lib/earthquake/ext.rb +1 -1
- data/lib/earthquake/get_access_token.rb +1 -1
- data/lib/earthquake/input.rb +11 -0
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.9
|
data/earthquake.gemspec
CHANGED
data/lib/earthquake/commands.rb
CHANGED
@@ -19,7 +19,7 @@ Earthquake.init do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
command :update do |m|
|
22
|
-
|
22
|
+
async_e { twitter.update(m[1]) } if confirm("update '#{m[1]}'")
|
23
23
|
end
|
24
24
|
|
25
25
|
command %r|^[^:\$].*| do |m|
|
@@ -32,7 +32,7 @@ Earthquake.init do
|
|
32
32
|
screen_name = target["user"]["screen_name"]
|
33
33
|
text = "@#{screen_name} #{m[2]}"
|
34
34
|
if confirm(["'@#{screen_name}: #{target["text"]}'", "reply '#{text}'"].join("\n"))
|
35
|
-
|
35
|
+
async_e { twitter.update(text, :in_reply_to_status_id => in_reply_to_status_id) }
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -53,7 +53,7 @@ Earthquake.init do
|
|
53
53
|
|
54
54
|
command :delete do |m|
|
55
55
|
tweet = twitter.status(m[1])
|
56
|
-
|
56
|
+
async_e { twitter.status_destroy(m[1]) } if confirm("delete '#{tweet["text"]}'")
|
57
57
|
end
|
58
58
|
|
59
59
|
command :mentions do
|
@@ -61,11 +61,11 @@ Earthquake.init do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
command :follow do |m|
|
64
|
-
|
64
|
+
async_e { twitter.friend(m[1]) }
|
65
65
|
end
|
66
66
|
|
67
67
|
command :unfollow do |m|
|
68
|
-
|
68
|
+
async_e { twitter.unfriend(m[1]) }
|
69
69
|
end
|
70
70
|
|
71
71
|
command :recent do
|
@@ -105,7 +105,7 @@ Earthquake.init do
|
|
105
105
|
command %r|^:retweet\s+(\d+)$|, :as => :retweet do |m|
|
106
106
|
target = twitter.status(m[1])
|
107
107
|
if confirm("retweet 'RT @#{target["user"]["screen_name"]}: #{target["text"]}'")
|
108
|
-
|
108
|
+
async_e { twitter.retweet(m[1]) }
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
@@ -113,21 +113,21 @@ Earthquake.init do
|
|
113
113
|
target = twitter.status(m[1])
|
114
114
|
text = "#{m[2]} RT @#{target["user"]["screen_name"]}: #{target["text"]} (#{target["id"]})"
|
115
115
|
if confirm("unofficial retweet '#{text}'")
|
116
|
-
|
116
|
+
async_e { twitter.update(text) }
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
120
|
command :favorite do |m|
|
121
121
|
tweet = twitter.status(m[1])
|
122
122
|
if confirm("favorite '#{tweet["user"]["screen_name"]}: #{tweet["text"]}'")
|
123
|
-
|
123
|
+
async_e { twitter.favorite(m[1]) }
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
127
|
command :unfavorite do |m|
|
128
128
|
tweet = twitter.status(m[1])
|
129
129
|
if confirm("unfavorite '#{tweet["user"]["screen_name"]}: #{tweet["text"]}'")
|
130
|
-
|
130
|
+
async_e { twitter.unfavorite(m[1]) }
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
@@ -144,15 +144,15 @@ Earthquake.init do
|
|
144
144
|
end
|
145
145
|
|
146
146
|
command :block do |m|
|
147
|
-
|
147
|
+
async_e { twitter.block(m[1]) }
|
148
148
|
end
|
149
149
|
|
150
150
|
command :unblock do |m|
|
151
|
-
|
151
|
+
async_e { twitter.unblock(m[1]) }
|
152
152
|
end
|
153
153
|
|
154
154
|
command :report_spam do |m|
|
155
|
-
|
155
|
+
async_e { twitter.report_spam(m[1]) }
|
156
156
|
end
|
157
157
|
|
158
158
|
command :messages do
|
@@ -170,7 +170,7 @@ Earthquake.init do
|
|
170
170
|
end
|
171
171
|
|
172
172
|
command %r|^:message (\w+)\s+(.*)|, :as => :message do |m|
|
173
|
-
|
173
|
+
async_e { twitter.message(*m[1, 2]) } if confirm("message '#{m[2]}' to @#{m[1]}")
|
174
174
|
end
|
175
175
|
|
176
176
|
command :reconnect do
|
data/lib/earthquake/core.rb
CHANGED
@@ -92,6 +92,7 @@ module Earthquake
|
|
92
92
|
Readline::HISTORY.pop if buf.empty? || Readline::HISTORY[-1] == Readline::HISTORY[-2]
|
93
93
|
end
|
94
94
|
sync { input(buf.strip) }
|
95
|
+
sleep 1 if buf.present?
|
95
96
|
end
|
96
97
|
end
|
97
98
|
|
@@ -99,16 +100,14 @@ module Earthquake
|
|
99
100
|
loop do
|
100
101
|
if Readline.line_buffer.nil? || Readline.line_buffer.empty?
|
101
102
|
sync { output }
|
102
|
-
sleep 1
|
103
|
-
else
|
104
|
-
sleep 2
|
105
103
|
end
|
104
|
+
sleep 1
|
106
105
|
end
|
107
106
|
end
|
108
107
|
|
109
108
|
reconnect
|
110
109
|
|
111
|
-
trap('
|
110
|
+
trap('INT') { stop }
|
112
111
|
end
|
113
112
|
end
|
114
113
|
|
data/lib/earthquake/ext.rb
CHANGED
@@ -9,7 +9,7 @@ module Earthquake
|
|
9
9
|
request_token = consumer.get_request_token
|
10
10
|
|
11
11
|
puts "1) open: #{request_token.authorize_url}"
|
12
|
-
Launchy::Browser.run(request_token.authorize_url)
|
12
|
+
Launchy::Browser.run(request_token.authorize_url) rescue nil
|
13
13
|
|
14
14
|
print "2) Enter the PIN: "
|
15
15
|
pin = STDIN.gets.strip
|
data/lib/earthquake/input.rb
CHANGED
@@ -81,6 +81,17 @@ module Earthquake
|
|
81
81
|
raise "type must be :y or :n"
|
82
82
|
end
|
83
83
|
end
|
84
|
+
|
85
|
+
def async_e(&block)
|
86
|
+
async { handle_api_error(&block) }
|
87
|
+
end
|
88
|
+
|
89
|
+
def handle_api_error(&block)
|
90
|
+
result = block.call
|
91
|
+
if result["error"]
|
92
|
+
notify "[ERROR] #{result["error"]}"
|
93
|
+
end
|
94
|
+
end
|
84
95
|
end
|
85
96
|
|
86
97
|
init do
|