lita-destiny 0.2.1 → 0.2.2
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.
- checksums.yaml +4 -4
- data/lib/lita/handlers/destiny.rb +42 -7
- data/lita-destiny.gemspec +1 -1
- data/spec/lita/handlers/destiny_spec.rb +14 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01223fac8c8c2ec41489c1be0a51f65666654f98
|
4
|
+
data.tar.gz: d8198502f5bfd9e4b9683465af858eb550b27523
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c9c7aac948126b416050df65186068299456e1ba93acaa13a35ce315c967a79282b5ab582e4a909bc25c08e6f6f7f6d1adfb44b31d2b562f2f4aba511e1203e
|
7
|
+
data.tar.gz: ef0f14ed1ad7d113d81e8e89be8d4d3268fd21a6d88fcb4460c96670a9190bf22b12afc2c7f63e58eda9aeb7a62e8ba1ddb573f5c6b16738ab66195d8eaa1c91
|
@@ -22,6 +22,7 @@ module Lita
|
|
22
22
|
# Xur Route
|
23
23
|
route(/^!(xur)/i, :xur , help: { "!xur" => "Get Xur's inventory when availible" })
|
24
24
|
|
25
|
+
# PoE Routes
|
25
26
|
route(/^!(poe32)/i, :poe_32, help: { "!32" => "Get this weeks level 32 Prison of Elders information." })
|
26
27
|
|
27
28
|
route(/^!(poe34)/i, :poe_34, help: { "!34" => "Get this weeks level 34 Prison of Elders information." })
|
@@ -36,8 +37,12 @@ module Lita
|
|
36
37
|
def nightfall(response)
|
37
38
|
# Set up our client
|
38
39
|
destiny_client = Destiny::Client.new(api_key)
|
40
|
+
# Set attachment color
|
41
|
+
color = "#d35400"
|
42
|
+
# Set attachment thumb_url
|
43
|
+
thumb_url = "http://i.imgur.com/J9oBqJK.png"
|
39
44
|
# Build the activity message with nightfall info
|
40
|
-
build_activity_message(destiny_client.nightfall, response)
|
45
|
+
build_activity_message(destiny_client.nightfall, response, color, thumb_url)
|
41
46
|
end
|
42
47
|
|
43
48
|
# Weekly Strike Activity Method
|
@@ -48,8 +53,12 @@ module Lita
|
|
48
53
|
def weekly(response)
|
49
54
|
# Set up our client
|
50
55
|
destiny_client = Destiny::Client.new(api_key)
|
56
|
+
# Set attachment color
|
57
|
+
color = "#f39c12"
|
58
|
+
# Set attachment thumb_url
|
59
|
+
thumb_url = "http://i.imgur.com/HhXoUCX.png"
|
51
60
|
# Build the activity message with weekly info
|
52
|
-
build_activity_message(destiny_client.weekly_strike, response)
|
61
|
+
build_activity_message(destiny_client.weekly_strike, response, color, thumb_url)
|
53
62
|
end
|
54
63
|
|
55
64
|
# Xur Items Method
|
@@ -58,7 +67,9 @@ module Lita
|
|
58
67
|
# Returns Xur inventory when availible.
|
59
68
|
#
|
60
69
|
def xur(response)
|
61
|
-
|
70
|
+
# Set attachment color
|
71
|
+
color = "#9b59b6"
|
72
|
+
build_xur_message(response, color)
|
62
73
|
end
|
63
74
|
|
64
75
|
def poe_32(response)
|
@@ -88,10 +99,34 @@ module Lita
|
|
88
99
|
# Used by activity methods to bring concise activity info
|
89
100
|
# into the chat.
|
90
101
|
#
|
91
|
-
def build_activity_message(activity, response)
|
92
|
-
|
93
|
-
|
94
|
-
|
102
|
+
def build_activity_message(activity, response, color, thumb_url)
|
103
|
+
skull_fields = []
|
104
|
+
activity[:skulls].each do |skull|
|
105
|
+
skull_hash = {
|
106
|
+
title: skull,
|
107
|
+
value: "",
|
108
|
+
short: true
|
109
|
+
}
|
110
|
+
skull_fields << skull_hash
|
111
|
+
end
|
112
|
+
# Create our attachment structure
|
113
|
+
attachment_options = {
|
114
|
+
|
115
|
+
color: "#d35400",
|
116
|
+
|
117
|
+
title: "#{activity[:activityName]}",
|
118
|
+
|
119
|
+
text: "#{activity[:activityDescription]}",
|
120
|
+
|
121
|
+
fields: skull_fields,
|
122
|
+
|
123
|
+
thumb_url: thumb_url
|
124
|
+
}
|
125
|
+
|
126
|
+
text = "#{activity[:activityDescription]}"
|
127
|
+
# Create Attachment
|
128
|
+
attachment = Lita::Adapters::Slack::Attachment.new(text, attachment_options)
|
129
|
+
robot.chat_service.send_attachments(response.room, attachment)
|
95
130
|
end
|
96
131
|
|
97
132
|
# Xur Response Method
|
data/lita-destiny.gemspec
CHANGED
@@ -1,13 +1,22 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Lita::Handlers::
|
3
|
+
describe Lita::Handlers::DestinyHandler, lita_handler: true do
|
4
4
|
let(:api_key) { 'd319ebf361e9f4f28e65fa05ce1cf8d6' }
|
5
|
-
let(:config) { Lita::Handlers::
|
6
|
-
|
5
|
+
let(:config) { Lita::Handlers::DestinyHandler.configuration_builder.build }
|
6
|
+
|
7
7
|
before do
|
8
8
|
config.api_key = api_key
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
it { is_expected.to route_command("!nightfall").to(:nightfall)}
|
12
|
-
|
12
|
+
|
13
|
+
it { is_expected.to route_command("!weekly").to(:weekly)}
|
14
|
+
|
15
|
+
it { is_expected.to route_command("!xur").to(:xur)}
|
16
|
+
|
17
|
+
it { is_expected.to route_command("!poe32").to(:poe_32)}
|
18
|
+
|
19
|
+
it { is_expected.to route_command("!poe34").to(:poe_34)}
|
20
|
+
|
21
|
+
it { is_expected.to route_command("!poe35").to(:poe_35)}
|
13
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-destiny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PDaily
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|