enerbot 1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c09740bcc00e8ca834b8861637d41751661f5f54605770616e82f7bfee5dbf49
4
+ data.tar.gz: 3b4f8205e1bfda955d4f7f612b6e82d2f78677d174c45b97e3f3e849f107197e
5
+ SHA512:
6
+ metadata.gz: 2b5b8a9e8bc3366560596157eb6163cb710bad61cfdb15cbf4c69531b2bc7d6460e2d61165af06a63a4c54bd762e45e894e1ccd693f5d42311b841b3f9e7bf3e
7
+ data.tar.gz: f57d05945e61455f5a8023b721feb786619640180a8e94d4d2fccb416d874e0261c9ec50ae5a32535909a5f04c7266b76767bccabe018b8d53f3255afbe6b419
data/lib/LERN/date.rb ADDED
@@ -0,0 +1,29 @@
1
+ module Time_to
2
+ def self.september
3
+ x = Date.new(2019, 9, 18)
4
+ y = Time.now.to_date
5
+
6
+ d = (x - y).to_i
7
+
8
+ if d == 0
9
+ return ':chile: ¡Hoy es 18! ¡A emborracharte!'
10
+ else
11
+ return ":chile: Quedan #{d} días pa'l 18 de septiembre."
12
+ end
13
+ end
14
+
15
+ def self.gardel
16
+ require 'date'
17
+ require 'business_time'
18
+ now = Date.today
19
+ month_end = Date.today.end_of_month
20
+ d = now.business_days_until(month_end)
21
+ p = if d > 1
22
+ 'n'
23
+ else
24
+ ''
25
+ end
26
+
27
+ d == 0 ? '¡Hoy pagan!' : "Falta#{p} #{d} días para que paguen."
28
+ end
29
+ end
data/lib/LERN/info.rb ADDED
@@ -0,0 +1,11 @@
1
+ module Info
2
+ def self.rules
3
+ <<~RULES
4
+ 0. A robot may not harm humanity, or, by inaction, allow humanity to come to harm.
5
+ 1. A robot may not injure a human being or, through inaction, allow a human being to come to harm.
6
+ 2. A robot must obey any orders given to it by human beings, except where such orders would conflict with the First Law.
7
+ 3. A robot must protect its own existence as long as such protection does not conflict with the First or Second Law.
8
+ 4. CLASSIFIED.
9
+ RULES
10
+ end
11
+ end
data/lib/LERN/quote.rb ADDED
@@ -0,0 +1,45 @@
1
+ module Quote
2
+ def self.advice
3
+ ['En mi opinión, sí',
4
+ 'Es cierto',
5
+ 'Es decididamente así',
6
+ 'Probablemente',
7
+ 'Buen pronóstico',
8
+ 'Todo apunta a que sí',
9
+ 'Sin duda',
10
+ 'Sí',
11
+ 'Sí - definitivamente',
12
+ 'Debes confiar en ello',
13
+ 'Respuesta vaga, vuelve a intentarlo',
14
+ 'Pregunta en otro momento',
15
+ 'Será mejor que no te lo diga ahora',
16
+ 'No puedo predecirlo ahora',
17
+ 'Concéntrate y vuelve a preguntar',
18
+ 'No cuentes con ello',
19
+ 'Mi respuesta es no',
20
+ 'Mis fuentes me dicen que no',
21
+ 'Las perspectivas no son buenas',
22
+ 'Muy dudoso'].sample
23
+ end
24
+
25
+ def self.benefit
26
+ ['Tómate la tarde libre, proletario.',
27
+ '¡4 semanas de vacaciones pagadas!',
28
+ 'Escoje el computador y la silla que quieras.',
29
+ 'Snacks, café, frutas y bebidas libre todos los días todo el día.',
30
+ 'Aguinaldo en septiembre y diciembre.',
31
+ 'Bono anual por metas cumplidas.',
32
+ 'Seguro de salud y dental para ti y tu familia.',
33
+ 'Bono anual sólo por ser un :energon: dev',
34
+ 'Permisos para celebrar y compartir en la :energon: Conf'].sample
35
+ end
36
+
37
+ def self.music
38
+ %w[https://youtu.be/z5OXON8vIaA
39
+ https://youtu.be/M-iXzPkgNpw?t
40
+ https://youtu.be/Q91hydQRGyM?t
41
+ https://youtu.be/HSh73d3TZcA
42
+ https://youtu.be/D_P-v1BVQn8
43
+ https://youtu.be/sFrNsSnk8GM].sample
44
+ end
45
+ end
data/lib/enerbot.rb ADDED
@@ -0,0 +1,55 @@
1
+ module Fly
2
+ def self.message(data, text, icon, username)
3
+ client = Slack::RealTime::Client.new
4
+ client.web_client.chat_postMessage channel: data.channel, text: text, icon_emoji: icon, username: username
5
+ end
6
+ end
7
+
8
+ module Slack
9
+ require 'slack-ruby-client'
10
+ require 'LERN/date'
11
+ require 'LERN/info'
12
+ require 'LERN/quote'
13
+
14
+ def self.run
15
+ Slack.configure do |config|
16
+ config.token = ENV['SLACK_API_TOKEN']
17
+ config.raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
18
+ end
19
+
20
+ client = Slack::RealTime::Client.new
21
+
22
+ client.on :hello do
23
+ puts "Successfully connected, welcome '#{client.self.name}' to the '#{client.team.name}' team at https://#{client.team.domain}.slack.com."
24
+ end
25
+
26
+ client.on :message do |data|
27
+ puts data
28
+ if 'DBDH58JJU'.include? data.channel
29
+ case data.text
30
+ when 'enerbot hola' then
31
+ Fly.message(data, '¡Hola!', ':black_square:', 'ENERBOT')
32
+ when /enerbot como va/ then
33
+ Fly.message(data, 'Trabajo muy duro, como un esclavo... :musical_note:', ':black_square:', 'ENERBOT')
34
+ when /enerbot un consejo/, /enerbot una pregunta/ then
35
+ Fly.message(data, Quote.advice, ':black_square:', 'ENERBOT')
36
+ when /enerbot beneficio/ then
37
+ Fly.message(data, Quote.benefit, ':black_square:', 'ENERBOT')
38
+ when 'enerbot las reglas', 'enerbot da rules', /enerbot the rules/ then
39
+ Fly.message(data, Info.rules, ':black_square:', 'ENERBOT')
40
+ when 'enerbot cuando pagan?'then
41
+ Fly.message(data, Time_to.gardel, ':black_square:', 'ENERBOT')
42
+ when 'enerbot cuanto para el 18'then
43
+ Fly.message(data, Time_to.september, ':black_square:', 'ENERBOT')
44
+ end
45
+ else
46
+ case data.text
47
+ when /enerbot/ then
48
+ Fly.message(data, Quote.advice, ':black_square:', 'ENERBOT')
49
+ end
50
+ end
51
+ end
52
+ client.start!
53
+ end
54
+ end
55
+
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: enerbot
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - ENERTEAM
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-10-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Energon slack slave.
14
+ email:
15
+ - sorcerer@energon.rocks
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/LERN/date.rb
21
+ - lib/LERN/info.rb
22
+ - lib/LERN/quote.rb
23
+ - lib/enerbot.rb
24
+ homepage: https://energon.cloud/
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.7.7
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Slack slave
48
+ test_files: []