google-voice 0.2.1 → 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/VERSION +1 -1
- data/lib/google/voice/sms.rb +15 -30
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/lib/google/voice/sms.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# coding: UTF-8
|
2
2
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'base')
|
3
3
|
|
4
|
-
GOOGLE_VOICE_SMS_TYPE = 11
|
5
|
-
|
6
4
|
module Google
|
7
5
|
module Voice
|
8
6
|
class Sms < Base
|
@@ -20,40 +18,27 @@ module Google
|
|
20
18
|
def recent
|
21
19
|
@curb.url = "https://www.google.com/voice/inbox/recent/"
|
22
20
|
@curb.http_get
|
23
|
-
sms = []
|
24
21
|
doc = Nokogiri::XML::Document.parse(@curb.body_str)
|
25
22
|
data = doc.xpath('/response/json').first.text
|
26
23
|
html = Nokogiri::HTML::DocumentFragment.parse(doc.to_html)
|
27
24
|
json = JSON.parse(data)
|
28
25
|
# Format for messages is [id, {attributes}]
|
29
|
-
json['messages'].
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
:time => row.css('span.gc-message-sms-time').inner_html
|
43
|
-
}
|
44
|
-
end
|
45
|
-
end
|
46
|
-
# Google is using milliseconds since epoch for time
|
47
|
-
sms << {
|
48
|
-
:id => message[0],
|
49
|
-
:phone_number => message[1]['phoneNumber'],
|
50
|
-
:start_time => Time.at(message[1]['startTime'].to_i / 1000),
|
51
|
-
:messages => messages}
|
26
|
+
json['messages'].map do |conversation|
|
27
|
+
next unless conversation[1]['labels'].include? "sms"
|
28
|
+
html.css("##{conversation[0]} div.gc-message-sms-row").map do |row|
|
29
|
+
next if row.css('span.gc-message-sms-from').inner_html.strip! =~ /Me:/
|
30
|
+
text = row.css('span.gc-message-sms-text').inner_html
|
31
|
+
time = row.css('span.gc-message-sms-time').inner_html
|
32
|
+
from = conversation[1]['phoneNumber']
|
33
|
+
{
|
34
|
+
:id => Digest::SHA1.hexdigest(conversation[0]+text+from),
|
35
|
+
:text => text,
|
36
|
+
:time => time,
|
37
|
+
:from => from
|
38
|
+
}
|
52
39
|
end
|
53
|
-
end
|
54
|
-
sms
|
40
|
+
end.flatten.compact
|
55
41
|
end
|
56
|
-
|
57
42
|
end
|
58
43
|
end
|
59
|
-
end
|
44
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 3
|
9
|
+
version: 0.2.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jeff Rafter
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-02 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|