yamwow 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
@@ -60,7 +60,9 @@ module YamWow
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def build_messages(messages_data, reference_data)
|
63
|
-
messages_data.select { |m| m['replied_to_id'].nil? }
|
63
|
+
messages_data.select { |m| m['replied_to_id'].nil? }.each do |m|
|
64
|
+
m['like_count'] = m['liked_by']['count'].to_i
|
65
|
+
end
|
64
66
|
end
|
65
67
|
|
66
68
|
def limit_reached
|
@@ -13,7 +13,39 @@ module YamWow
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def get_messages_with_praise_topic
|
16
|
-
MessagesWithTopicRequest.new(@client, 'praise', @options).send
|
16
|
+
r = MessagesWithTopicRequest.new(@client, 'praise', @options).send
|
17
|
+
r.data.each do |m|
|
18
|
+
m['reason'] = reason m
|
19
|
+
m['recipient_names'] = recipient_names m
|
20
|
+
m['recipient_tags'] = recipient_tags m
|
21
|
+
end
|
22
|
+
r
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def reason(message)
|
28
|
+
begin
|
29
|
+
attachments = message['attachments'] || []
|
30
|
+
praise_attachment = attachments.select { |a| a['type'] == 'ymodule' }.select { |a| a['ymodule']['app_id'] == 'praise' }.first
|
31
|
+
praise_attachment ? praise_attachment['name'].match(/Praise: (.+)/m)[1] : message['body']['parsed']
|
32
|
+
rescue
|
33
|
+
'(failed to extract reason)'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def recipient_names(message)
|
38
|
+
split_recipients(message['body']['plain']).map { |r| r.gsub '@', '' }.join ', '
|
39
|
+
end
|
40
|
+
|
41
|
+
def recipient_tags(message)
|
42
|
+
split_recipients(message['body']['parsed']).join ', '
|
43
|
+
end
|
44
|
+
|
45
|
+
def split_recipients(recipients)
|
46
|
+
recipients = recipients.include?('praised') ? recipients.match(/praised (.+)/)[1] : ''
|
47
|
+
recipients.gsub!(' and ', ', ')
|
48
|
+
recipients.split(', ')
|
17
49
|
end
|
18
50
|
|
19
51
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yamwow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: yam
|
16
|
-
requirement: &
|
16
|
+
requirement: &70109314411340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70109314411340
|
25
25
|
description:
|
26
26
|
email: matthew-github@matthewriley.name
|
27
27
|
executables: []
|