lita-onewheel-giphy 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lita/handlers/onewheel_giphy.rb +11 -3
- data/lita-onewheel-giphy.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfa1dd0b46f2a4c71b4cfc593723c8dc682a503a
|
4
|
+
data.tar.gz: 494274ff28d6af9107130741b021bc1f114a0e4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16845b263be20d199418b6af23e1fd09139bf918f6e01a0653679f1ccbc64b6edaf46eeb43b977e5b76acae3550cb30bcedd0543a72e45466468b1c39b985385
|
7
|
+
data.tar.gz: 7152e611516fdd9e8276918bb875aadef4c00f1464b7752feecc10eefec8a1b458933502ec078862665ed75b250ff9e9e1810d0b2f6d54e08243386385e88e78
|
@@ -15,7 +15,7 @@ module Lita
|
|
15
15
|
keywords = response.matches[0][0]
|
16
16
|
uri = get_search_uri(keywords)
|
17
17
|
giphy_data = call_giphy(uri)
|
18
|
-
image =
|
18
|
+
image = get_random(giphy_data.body)
|
19
19
|
response.reply image
|
20
20
|
end
|
21
21
|
|
@@ -42,9 +42,16 @@ module Lita
|
|
42
42
|
config.api_uri + 'random?' #?q=' + URI.encode(keywords)
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
45
|
+
def get_random(data)
|
46
46
|
image_data = JSON.parse(data)
|
47
|
-
image_data['data'][
|
47
|
+
image_data['data'][get_random_number(image_data['data'].count)]['images']['original']['url']
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_random_number(max)
|
51
|
+
and_i = Random.new
|
52
|
+
so_far_away = and_i.rand(max)
|
53
|
+
puts "rand: #{so_far_away}"
|
54
|
+
so_far_away
|
48
55
|
end
|
49
56
|
|
50
57
|
def get_image(data)
|
@@ -53,6 +60,7 @@ module Lita
|
|
53
60
|
end
|
54
61
|
|
55
62
|
def call_giphy(uri)
|
63
|
+
Lita.logger.debug("Calling giphy with #{uri}")
|
56
64
|
RestClient.get uri + 'api_key=' + config.api_key
|
57
65
|
end
|
58
66
|
|
data/lita-onewheel-giphy.gemspec
CHANGED