lita-whoami 0.1.2 → 0.1.3
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 +4 -4
- data/README.md +8 -0
- data/lib/lita/handlers/whoami.rb +31 -1
- data/lita-whoami.gemspec +1 -1
- data/spec/lita/handlers/whoami_spec.rb +24 -2
- 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: 69e5948d05c5ddc018d6b40e653bae4339aa1232
|
4
|
+
data.tar.gz: 43de801aaeadc018f63ef06ba74217ccba93d3e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c35550acf2c4194fd7bbd93697b0d5294d883feed7685742c3a1e64fa859585114314543ea500c4a0c3e7db3d242487da26029607c6fd68c895516f8fe86c13a
|
7
|
+
data.tar.gz: 33a521202de2af893cb20cdb2d149bc3a32dbf615f1313cc7f3ec9a3b388270eb59d1e28faa7f4e50db9de4ae5d8665652cb6c3044acf58a80ca76ab97e85d7f
|
data/README.md
CHANGED
data/lib/lita/handlers/whoami.rb
CHANGED
@@ -7,14 +7,30 @@ module Lita
|
|
7
7
|
"SOMEONE is SOMETHING" => "Tell everbot that someone is something."
|
8
8
|
})
|
9
9
|
|
10
|
+
route(/^(\w+) isn['’‘]t (.+)/, :unassign_person, command: true, help: {
|
11
|
+
"SOMEONE isn't SOMETHING" => "Tell everbot that someone is not something."
|
12
|
+
})
|
13
|
+
|
10
14
|
route(/^who ?is (\w+)/, :describe_person, command: true, help: {
|
11
15
|
"who is PERSON" => "Everbot will tell you who somebody is."
|
12
16
|
})
|
13
17
|
|
18
|
+
route(/^(i|I) don['’‘]t know who anyone is/, :describe_everyone, command: true, help: {
|
19
|
+
"who is PERSON" => "Everbot will tell you who somebody is."
|
20
|
+
})
|
21
|
+
|
14
22
|
def key_for_person name
|
15
23
|
"#{REDIS_KEY}:#{name}"
|
16
24
|
end
|
17
25
|
|
26
|
+
def describe_everyone(chat)
|
27
|
+
chat.reply redis.keys
|
28
|
+
.select { |key| key.include?(REDIS_KEY) }
|
29
|
+
.map { |key| key.split(':').last }
|
30
|
+
.map { |person| person + " is " + get_descriptiors_for(person).join(', ') }
|
31
|
+
.join("\n\n")
|
32
|
+
end
|
33
|
+
|
18
34
|
def assign_person(chat)
|
19
35
|
name, thing = chat.matches[0]
|
20
36
|
|
@@ -25,14 +41,28 @@ module Lita
|
|
25
41
|
chat.reply "Okay, #{name} is #{thing}!"
|
26
42
|
end
|
27
43
|
|
44
|
+
def unassign_person(chat)
|
45
|
+
name, thing = chat.matches[0]
|
46
|
+
|
47
|
+
return if name == 'who'
|
48
|
+
|
49
|
+
redis.lrem key_for_person(name), 0, thing
|
50
|
+
|
51
|
+
chat.reply "Okay, #{name} is not #{thing}."
|
52
|
+
end
|
53
|
+
|
28
54
|
def describe_person(chat)
|
29
55
|
name = chat.matches[0][0]
|
30
56
|
|
31
|
-
descriptors =
|
57
|
+
descriptors = get_descriptiors_for(name)
|
32
58
|
|
33
59
|
chat.reply "#{name} is #{descriptors.join ', '}"
|
34
60
|
end
|
35
61
|
|
62
|
+
def get_descriptiors_for(name)
|
63
|
+
redis.lrange(key_for_person(name), 0, -1).uniq
|
64
|
+
end
|
65
|
+
|
36
66
|
Lita.register_handler(self)
|
37
67
|
end
|
38
68
|
end
|
data/lita-whoami.gemspec
CHANGED
@@ -11,11 +11,33 @@ describe Lita::Handlers::Whoami, lita_handler: true do
|
|
11
11
|
|
12
12
|
it "Can tell you what people are." do
|
13
13
|
send_command("taylor is a bad programmer")
|
14
|
-
|
15
|
-
|
14
|
+
send_command("who is taylor")
|
15
|
+
|
16
|
+
expect(replies.last).to eq "taylor is a bad programmer"
|
17
|
+
expect(replies.count).to eq 2
|
18
|
+
end
|
16
19
|
|
20
|
+
it "Can unassign a descriptior from someone." do
|
21
|
+
send_command("taylor is a bad programmer")
|
17
22
|
send_command("who is taylor")
|
23
|
+
|
18
24
|
expect(replies.last).to eq "taylor is a bad programmer"
|
19
25
|
expect(replies.count).to eq 2
|
26
|
+
|
27
|
+
send_command("taylor isn't a bad programmer")
|
28
|
+
expect(replies.last).to eq "Okay, taylor is not a bad programmer."
|
29
|
+
expect(replies.count).to eq 3
|
30
|
+
|
31
|
+
send_command("who is taylor")
|
32
|
+
expect(replies.last).to eq "taylor is "
|
33
|
+
end
|
34
|
+
|
35
|
+
it "Can describe everyone" do
|
36
|
+
send_command("taylor is a bad programmer")
|
37
|
+
send_command("danny is a mediocre programmer")
|
38
|
+
|
39
|
+
send_command("I don't know who anyone is")
|
40
|
+
expect(replies.last).to include 'taylor is a bad programmer'
|
41
|
+
expect(replies.last).to include 'danny is a mediocre programmer'
|
20
42
|
end
|
21
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-whoami
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Lapeyre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|