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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d10d512ce69617b184b6d25b09ed9d0e33a293a
4
- data.tar.gz: cb9cd263f423fd32bd470faee6e8031f3653b7bb
3
+ metadata.gz: bfa1dd0b46f2a4c71b4cfc593723c8dc682a503a
4
+ data.tar.gz: 494274ff28d6af9107130741b021bc1f114a0e4c
5
5
  SHA512:
6
- metadata.gz: cf027904217afe14dfd87df72f11b0822f355fbfc4a4c888872bcfe1f64155d6d6600233d697a4d1863b100b2b876b4e0545a37746afd2d57c4df8f79442b018
7
- data.tar.gz: 3974c76851f7c7c7c5edd64fa79cb4496a3974b0d102609f30b9d364a9492c95ac0f5c66047af44d8950bac133cba05686d40c31e7c49052eafafb59132d249a
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 = get_first(giphy_data.body)
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 get_first(data)
45
+ def get_random(data)
46
46
  image_data = JSON.parse(data)
47
- image_data['data'][0]['images']['original']['url']
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
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-giphy'
3
- spec.version = '0.0.1'
3
+ spec.version = '0.1.0'
4
4
  spec.authors = ['Andrew Kreps']
5
5
  spec.email = ['andrew.kreps@gmail.com']
6
6
  spec.description = 'Lita chat interface to giphy api for MOAR GIFS'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-onewheel-giphy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kreps