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 +4 -4
- data/lib/lita/handlers/good_morning.rb +51 -4
- data/lib/lita-good-morning.rb +2 -1
- data/lita-good-morning.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dae21cc5f96dc834d0f44df1bc7806b319ac40ec
|
4
|
+
data.tar.gz: 24d369a4044e270c0ed980fa798d97b6104eef06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
7
|
-
|
8
|
-
|
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)
|
data/lib/lita-good-morning.rb
CHANGED
@@ -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(
|
data/lita-good-morning.gemspec
CHANGED
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.
|
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-
|
11
|
+
date: 2015-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|