lita-whoami 0.1.2 → 0.1.3

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: 3d04c06a52345fed5914f36d3bd159ff96043fa0
4
- data.tar.gz: 1f03a8757d45f60e61f0807f94843e1564f16167
3
+ metadata.gz: 69e5948d05c5ddc018d6b40e653bae4339aa1232
4
+ data.tar.gz: 43de801aaeadc018f63ef06ba74217ccba93d3e1
5
5
  SHA512:
6
- metadata.gz: 349628b16b2276cb287411aac7d3d3e4db3e3092b4c35fccbd82c7fb42bc77213ac468b80297a5e815066edf3d14086c6d1cc53c48f0240cbc48dd0c1a96993f
7
- data.tar.gz: e90cb8d87a6a48ac9b8792c8ae3757ac3df9ef8a6e2c20b796f86646b5d8e62e241eb361e6cd2f80f96c9627c0c8d352ac5a329e393ab49d63f05407c7012840
6
+ metadata.gz: c35550acf2c4194fd7bbd93697b0d5294d883feed7685742c3a1e64fa859585114314543ea500c4a0c3e7db3d242487da26029607c6fd68c895516f8fe86c13a
7
+ data.tar.gz: 33a521202de2af893cb20cdb2d149bc3a32dbf615f1313cc7f3ec9a3b388270eb59d1e28faa7f4e50db9de4ae5d8665652cb6c3044acf58a80ca76ab97e85d7f
data/README.md CHANGED
@@ -19,3 +19,11 @@ lita taylor is a bad programmer
19
19
  ```
20
20
  lita who is taylor
21
21
  ```
22
+
23
+ ```
24
+ lita taylor isn't a bad programmer
25
+ ```
26
+
27
+ ```
28
+ lita I don't know who anyone is
29
+ ```
@@ -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 = redis.lrange(key_for_person(name), 0, -1).uniq
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-whoami"
3
- spec.version = "0.1.2"
3
+ spec.version = "0.1.3"
4
4
  spec.authors = ["Taylor Lapeyre"]
5
5
  spec.email = ["taylorlapeyre@gmail.com"]
6
6
  spec.description = "Allows you to tell Lita who people are."
@@ -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
- expect(replies).to_not be_empty
15
- expect(replies.last).to eq "Okay, taylor is a bad programmer!"
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.2
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-18 00:00:00.000000000 Z
11
+ date: 2015-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita