lita-good-morning 0.1.0 → 0.1.1

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: c1e418d02dae7cf1d8c4df6dc2da8db2b0e3eada
4
- data.tar.gz: ea3f49b2a37f6d71a9484b506aa86e6424808fbc
3
+ metadata.gz: dae21cc5f96dc834d0f44df1bc7806b319ac40ec
4
+ data.tar.gz: 24d369a4044e270c0ed980fa798d97b6104eef06
5
5
  SHA512:
6
- metadata.gz: 3e5fb9746c7cb6ee68474d98048c60aa2c1a4a823f4f37d96ebe3c79fdc2325984fac26091f69582516713fa0793ec93a81c9a0800da90deb3fd772310b59d26
7
- data.tar.gz: 7c88c4b74d83dab0317f2c9839204203021b0ece8b9852779f60ba11863b5064995d4b84bd34b20308274de165cefc33f4de14c2a33681b417b933d39e933b38
6
+ metadata.gz: 104921e73699a33a35f49c3bfbc98197ebf929eb1c53a6fc60463bc348baed30ed2e94d9bd1433c681e412aca864b1978fde5f0ef888f86b277e2ad201ea82ca
7
+ data.tar.gz: 55bb3d9cb792a669970971e95165a79c9f62aaefb41df23bc6c975caf58a172f173d78ff3fdb8ad72e8e003189a9ece80d01fc2c4950898e545a6cdf72b3a663
@@ -1,11 +1,58 @@
1
1
  module Lita
2
2
  module Handlers
3
3
  class GoodMorning < Handler
4
- route(/^echo\s+(.+)/, :echo, help: { "echo TEXT" => "Retorna de volta TEXT." })
4
+ MESSAGES = [
5
+ 'Bom dia galera!',
6
+ 'Goodie Goodie Morning pessoal!',
7
+ 'Que esse dia seja produtivo e delicioso! Bom dia amigos!',
8
+ 'Bom dia.. e alegria.. vamos sorrir e cantar! Dia galera!',
9
+ 'DIAAAAAAAAA',
10
+ 'Bão dia fi!',
11
+ 'Bom Bom Bom Bom diaaaaaaaaaa!',
12
+ 'Woof Woof! Bom dia!',
13
+ 'Good morning america!',
14
+ 'A quem chega, bom dia! Let\'s get to work!',
15
+ 'Let\'s do it to it pessoal! Bom Dia!',
16
+ 'Bundinha! Quer dizer.. Bom dia!',
17
+ 'Dia rapeizee!',
18
+ 'Dia dia dia diiiiaaa!',
19
+ 'Mais um dia começando, que esse seja ótimo galera!']
5
20
 
6
- def echo(response)
7
- response.reply(response.matches)
8
- end
21
+ on :connected, :check_if_its_hello_time
22
+
23
+ route(/channel id/, :channel_id, command: true, help: 'Retorna o ID do canal')
24
+
25
+ def initialize(*args)
26
+ log.info 'Handler de bom dia inicializado!'
27
+ @room = Lita::Source.new(room: 'C03HUG8SG') # General
28
+ super
29
+ end
30
+
31
+ def channel_id(response)
32
+ response.reply_with_mention response.message.source.room
33
+ end
34
+
35
+ def check_if_its_hello_time(*_)
36
+ every(50) do |_|
37
+ Time.zone = 'Brasilia' # Needed since this will run in another thread..
38
+
39
+ # Todo dia de semana as 8 da manha...
40
+ send_good_morning_message #if Time.zone.now.strftime('%H:%M') == '08:00' &&
41
+ # ![0, 6].include?(Time.zone.now.wday)
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ def send_good_morning_message
48
+ # Only one good morning per day :)
49
+ return if redis.get 'gave_good_morning'
50
+
51
+ robot.send_message(@room, MESSAGES.sample)
52
+
53
+ redis.set 'gave_good_morning', true
54
+ redis.expire 'gave_good_morning', 60
55
+ end
9
56
  end
10
57
 
11
58
  Lita.register_handler(GoodMorning)
@@ -3,7 +3,8 @@ require "lita"
3
3
  Lita.load_locales Dir[File.expand_path(
4
4
  File.join("..", "..", "locales", "*.yml"), __FILE__
5
5
  )]
6
-
6
+ require 'active_support'
7
+ require 'active_support/core_ext'
7
8
  require "lita/handlers/good_morning"
8
9
 
9
10
  Lita::Handlers::GoodMorning.template_root File.expand_path(
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-good-morning"
3
- spec.version = "0.1.0"
3
+ spec.version = "0.1.1"
4
4
  spec.authors = ["Renan Gurgel"]
5
5
  spec.email = ["gurgel.renan@gmail.com"]
6
6
  spec.description = "Add a description"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-good-morning
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renan Gurgel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-28 00:00:00.000000000 Z
11
+ date: 2015-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita