lita-apod 0.5.0 → 0.6.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/apod.rb +52 -30
- data/lita-apod.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78562d5e39b6eac57eb555f66ed78f417f1800bb
|
4
|
+
data.tar.gz: 9eb18c8d3bcae8910c32bf6e0ea037f7a3b664a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48c05716359344993bf29617c39029510230ad57cbe06cfadfc3e0daee165897cf0235691214ceeaa12fbe096a9bbfd2a78992184a517734b78c6768b76dc251
|
7
|
+
data.tar.gz: 375ee9f45aec016c9044c97689564765e4300279c6a4373f3979963486318f17fd6ba80dab0fd890dcb069aafaacd6dacea0b45a91bbfa46205ef513d51c4a5e
|
data/lib/lita/handlers/apod.rb
CHANGED
@@ -1,62 +1,84 @@
|
|
1
1
|
module Lita
|
2
2
|
module Handlers
|
3
3
|
class Apod < Handler
|
4
|
-
|
5
4
|
config :apod_api_key
|
6
5
|
|
7
|
-
route(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
rando = Time.at(rand((Time.now - (60*60*24*365*5))..Time.now)).strftime('%Y-%m-%d')
|
6
|
+
route(/^apod\?$/i, command: true, help: {
|
7
|
+
'apod?' => 'Gives you a RANDOM pretty picture! Pulled random from the NASA Picture of the Day. https://apod.nasa.gov/'
|
8
|
+
}) do |response|
|
12
9
|
|
13
|
-
|
10
|
+
rando = Time.at(rand((Time.now - (60 * 60 * 24 * 365 * 5))..Time.now)).strftime('%Y-%m-%d')
|
14
11
|
|
15
12
|
res = http.get("https://api.nasa.gov/planetary/apod?api_key=#{config.apod_api_key}&date=#{rando}")
|
16
13
|
|
17
14
|
object = MultiJson.load(res.body)
|
18
15
|
|
19
|
-
|
16
|
+
if(robot.adapters.has_key?(:discord_oauth))
|
17
|
+
# uses the discordrb library to send an embedded image. very pretty
|
18
|
+
robot.chat_service.channel(response.room.id).send_embed do |embed|
|
19
|
+
embed.title = object['title']
|
20
|
+
embed.description = object['explanation']
|
21
|
+
embed.timestamp = Time.new(object['date']) # or whatever Time
|
22
|
+
embed.image = { url: object['hdurl'] }
|
23
|
+
embed.footer = object['copyright'] ? { text: 'Credit: ' << object['copyright'] } : nil
|
24
|
+
embed.color = '00CC00'
|
25
|
+
end
|
26
|
+
else
|
27
|
+
messageBody = ''
|
20
28
|
|
21
|
-
|
22
|
-
messageBody << "Image Credit: " + object['copyright']
|
23
|
-
end
|
29
|
+
messageBody << object['title'] + "\n"
|
24
30
|
|
25
|
-
|
31
|
+
if !object['copyright'].nil?
|
32
|
+
messageBody << "Image Credit: " + object['copyright']
|
33
|
+
end
|
26
34
|
|
27
|
-
|
28
|
-
messageBody << object['explanation']
|
35
|
+
messageBody << "\n\n"
|
29
36
|
|
30
|
-
|
37
|
+
messageBody << object['hdurl'] + "\n"
|
38
|
+
messageBody << object['explanation']
|
31
39
|
|
32
|
-
|
40
|
+
response.reply(messageBody)
|
41
|
+
end
|
33
42
|
|
34
|
-
|
35
|
-
"apod" => "Gives you a pretty picture! Pulled from the NASA Picture of the Day. https://apod.nasa.gov/"
|
36
|
-
}) do |response|
|
43
|
+
end
|
37
44
|
|
38
|
-
|
45
|
+
route(/^apod$/i, command: true, help: {
|
46
|
+
'apod' => 'Gives you a pretty picture! Pulled from the NASA Picture of the Day. https://apod.nasa.gov/'
|
47
|
+
}) do |response|
|
39
48
|
|
40
49
|
res = http.get("https://api.nasa.gov/planetary/apod?api_key=#{config.apod_api_key}")
|
41
50
|
|
42
51
|
object = MultiJson.load(res.body)
|
43
52
|
|
44
|
-
|
53
|
+
if(robot.adapters.has_key?(:discord_oauth))
|
54
|
+
# uses the discordrb library to send an embedded image. very pretty
|
55
|
+
robot.chat_service.channel(response.room.id).send_embed do |embed|
|
56
|
+
embed.title = object['title']
|
57
|
+
embed.description = object['explanation']
|
58
|
+
embed.timestamp = Time.new(object['date']) # or whatever Time
|
59
|
+
embed.image = { url: object['hdurl'] }
|
60
|
+
embed.footer = object['copyright'] ? { text: 'Credit: ' << object['copyright'] } : nil
|
61
|
+
embed.color = '00CC00'
|
62
|
+
end
|
63
|
+
else
|
64
|
+
messageBody = ''
|
45
65
|
|
46
|
-
|
47
|
-
messageBody << "Image Credit: " + object['copyright']
|
48
|
-
end
|
66
|
+
messageBody << object['title'] + "\n"
|
49
67
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
messageBody << object['explanation']
|
68
|
+
if !object['copyright'].nil?
|
69
|
+
messageBody << "Image Credit: " + object['copyright']
|
70
|
+
end
|
54
71
|
|
55
|
-
|
72
|
+
messageBody << "\n\n"
|
56
73
|
|
74
|
+
messageBody << object['hdurl'] + "\n"
|
75
|
+
messageBody << object['explanation']
|
76
|
+
|
77
|
+
response.reply(messageBody)
|
78
|
+
end
|
57
79
|
end
|
58
80
|
|
59
81
|
Lita.register_handler(self)
|
60
82
|
end
|
61
83
|
end
|
62
|
-
end
|
84
|
+
end
|
data/lita-apod.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-apod"
|
3
|
-
spec.version = "0.
|
3
|
+
spec.version = "0.6.0"
|
4
4
|
spec.authors = "John Celoria"
|
5
5
|
spec.email = "jceloria@gmail.com"
|
6
6
|
spec.description = "Pulls a picture using the NASA APOD (astronomy picture of the day) API endpoint"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-apod
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Celoria
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
version: '0'
|
134
134
|
requirements: []
|
135
135
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.
|
136
|
+
rubygems_version: 2.6.12
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: NASA Space Pictures
|