lita-destiny 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/destiny/destiny_api.rb +69 -67
- data/lib/lita/handlers/destiny.rb +20 -7
- data/lita-destiny.gemspec +1 -1
- 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: 273db0f6ec1165b2bfb680c9adb3dbb17784d983
|
4
|
+
data.tar.gz: 8a77938f5edd415ec959fe837f8f1d853c2b83e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93111e093fb4d5001ad794df9017067859138d5611984921fcf2fbc8fa0be319d80eb2334b639afc6cf1d9692f7d815df084c461f4ccb0d8ec42b3c70b835ff8
|
7
|
+
data.tar.gz: 88f9029bc6439c23e1fe82f871acd8e9597c5d66eac40d3d8034293263a99642fc5762703bd9cabd2601d8e85636e57c2a9e42a9d26b95f16cdbebf36f871458
|
data/lib/destiny/destiny_api.rb
CHANGED
@@ -1,83 +1,85 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module DestinyAPI
|
4
|
+
class Base
|
5
|
+
include HTTParty
|
6
|
+
format :json
|
7
|
+
base_uri 'www.bungie.net/platform/destiny/'
|
7
8
|
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
# Pull the days advisor report from http://www.bungie.net/platform/destiny/advisors/
|
16
|
-
# destiny.advisors
|
17
|
-
def advisors
|
18
|
-
raw_data = self.class.get('/advisors', headers: @headers)
|
19
|
-
parsed = raw_data.parsed_response['Response']['data']
|
20
|
-
end
|
10
|
+
# Init the Destiny API with Bungie API stored in ENV variable
|
11
|
+
# destiny = Destiny.new(api_token)
|
12
|
+
def initialize(api_token)
|
13
|
+
@headers = { 'X-API-Key' => api_token, 'Content-Type' => 'application/json' }
|
14
|
+
end
|
21
15
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
16
|
+
# Pull the days advisor report from http://www.bungie.net/platform/destiny/advisors/
|
17
|
+
# destiny.advisors
|
18
|
+
def advisors
|
19
|
+
raw_data = self.class.get('/advisors', headers: @headers)
|
20
|
+
parsed = raw_data.parsed_response['Response']['data']
|
27
21
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
|
23
|
+
def activity(activity_hash, raw=false)
|
24
|
+
raw_data = self.class.get("/manifest/activity/#{activity_hash}").parsed_response['Response']['data']['activity']
|
25
|
+
skulls = []
|
26
|
+
raw_data['skulls'].each do |skull|
|
27
|
+
skulls << skull['displayName']
|
28
|
+
end
|
29
|
+
unless raw == true
|
30
|
+
parsed_data = { activityName: raw_data['activityName'], activityDescription: raw_data['activityDescription'], skulls: skulls }
|
31
|
+
else
|
32
|
+
raw_data
|
33
|
+
end
|
32
34
|
end
|
33
|
-
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
# Pull the weekly nightfall info from http://www.bungie.net/platform/destiny/manifest/activity/#{activity_hash}
|
37
|
+
# Optional boolean argument, defaults to false from activity method to only return basic information for Lita bot.
|
38
|
+
#
|
39
|
+
# destiny.nightfall
|
40
|
+
#
|
41
|
+
def nightfall(options={})
|
42
|
+
nightfall_activity_hash = self.advisors['nightfallActivityHash']
|
43
|
+
activity(nightfall_activity_hash, boolean)
|
44
|
+
end
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
46
|
+
# Pull the weekly nightfall info from http://www.bungie.net/platform/destiny/manifest/activity/#{activity_hash}
|
47
|
+
# Returns an array of three items, only need one for the skulls and location.
|
48
|
+
#
|
49
|
+
# Optional boolean argument, defaults to false from activity method to return basic information for Lita bot.
|
50
|
+
#
|
51
|
+
# destiny.weekly_strike(false)
|
52
|
+
#
|
53
|
+
def weekly_strike(options={})
|
54
|
+
heroic_strike_hashes = self.advisors['heroicStrikeHashes']
|
55
|
+
activity(heroic_strike_hashes[0], boolean)
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
# Pull the weekly nightfall info from http://www.bungie.net/platform/destiny/manifest/activity/#{activity_hash}
|
59
|
+
#
|
60
|
+
#
|
61
|
+
# No known endpoints.
|
62
|
+
def arena(options={})
|
63
|
+
end
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
# WIP: Pull xur inventory
|
66
|
+
# http://www.bungie.net/platform/destiny/advisors/xur/?definitions=true
|
67
|
+
def xur
|
68
|
+
raw_data = self.class.get('/advisors/xur/?definitions=true').parsed_response['Response']['definitions']
|
69
|
+
end
|
69
70
|
|
70
|
-
|
71
|
-
|
72
|
-
|
71
|
+
# Pull the days bounties
|
72
|
+
def bounties
|
73
|
+
end
|
73
74
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
def place(place_hash)
|
76
|
+
raw data = self.class.get('/manifest/place/#{place_hash}').parsed_response['Response']['data']['place']
|
77
|
+
response = { place_name: raw_data['placeName'], place_desc: raw_data['placeDescription'] }
|
78
|
+
end
|
78
79
|
|
79
|
-
|
80
|
-
|
81
|
-
|
80
|
+
def destination(destination_hash)
|
81
|
+
raw_data = self.class.get('/manifest/destination/#{destination_hash}').parsed_response['Response']['data']
|
82
|
+
response = { dest_name: raw_data['destinationName'], dest_desc: raw_data['destinationDescription'] }
|
83
|
+
end
|
82
84
|
end
|
83
85
|
end
|
@@ -1,20 +1,33 @@
|
|
1
1
|
module Lita
|
2
2
|
module Handlers
|
3
3
|
class Destiny < Handler
|
4
|
-
|
5
|
-
|
4
|
+
namespace "destiny"
|
5
|
+
# Bring in DestinyAPI module
|
6
|
+
include DestinyAPI
|
6
7
|
|
7
|
-
|
8
|
+
# Required configuration attribute
|
9
|
+
config :api_key, type: String, required: true do
|
10
|
+
validate do |value|
|
11
|
+
"must be 32 characters" unless value.respond_to?(:size) && value.size == 32
|
12
|
+
end
|
13
|
+
end
|
8
14
|
|
9
|
-
|
15
|
+
|
16
|
+
# Set up our client
|
17
|
+
destiny_client = DestinyAPI::Base.new(config.api_key).call
|
18
|
+
|
19
|
+
|
20
|
+
route(/^!\w(.*)/i, :nightfall , help: { "!nightfall" => "Get this weeks nightfall description and skulls" })
|
10
21
|
|
11
22
|
|
23
|
+
def nightfall(response)
|
24
|
+
build_activity_message(destiny_client.nightfall, response)
|
25
|
+
end
|
12
26
|
|
13
27
|
# activity = { activityName: raw_data['activityName'], activityDescription: raw_data['activityDescription'], skulls: skulls }
|
14
|
-
def build_activity_message(activity)
|
28
|
+
def build_activity_message(activity, response)
|
15
29
|
activity = activity
|
16
|
-
|
17
|
-
response.reply("Hi!")
|
30
|
+
response.reply("#{activity["activityName"]}\n #{activityDescription["activityDescription"]}\n #{skulls["skulls"]}")
|
18
31
|
end
|
19
32
|
|
20
33
|
end
|
data/lita-destiny.gemspec
CHANGED
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.1.
|
4
|
+
version: 0.1.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-05-
|
11
|
+
date: 2015-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|