lita-greet 0.1.1 → 0.2.0

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: 7876a4856b3c1e691a3c18c18a94d7ee4f19ab1d
4
- data.tar.gz: fbc1f49b5ace7ab4ab712f15d55c21d4eb1b4108
3
+ metadata.gz: 1a26fa6c0394e2726c3192e5440877e818276a51
4
+ data.tar.gz: 4c36d70f3288f8d0ac335cbf26251d6b702a1f3e
5
5
  SHA512:
6
- metadata.gz: 4fa1e3ea940bd4c3aefaec242e2634113a694f75e3f050b7bf38dc3f5646847639c5ebf625676f03fd5340f92d412f09ba599eb5003c6a349793f1ab70598f13
7
- data.tar.gz: 675d0448b28027d9113739faaa6ec2d1a671db32646ac86d41aea9e56bc91a482e5e20e672f10c27f4a21278807326e78c8ebc1e14f252760d24834efc97ea2d
6
+ metadata.gz: 90a5c352f96dffa847fa85df6d8bf013e5c78239754626c221fadf87aa7e6a8b21e33c1c05eac987e7503cc1c5e1b339f1a085edc3d2e548c6b8bb24d5922c8d
7
+ data.tar.gz: e1b6ac2d821e0d2044060e07e674975fb4e164170e2de7aa8f608db1565cc1bd7eca96608524b9ce7f1fbc8fd1385a9926cc806190dd1987aa150bfad16bd799
@@ -2,22 +2,19 @@ module Lita
2
2
  module Handlers
3
3
  class Greet < Handler
4
4
 
5
- route(/^(hello|hi!?(| .*)$|good morning|howdy|yo!?$|hey).*/i, :say_hello)
5
+ route(/^(((ahoy|he+l{2,}+o+|he+y+|hi+)+( there)*)|go{2,}d (morning|afternoon|evening|night|nite)|greetings|howdy|sup|yo)+[!1?]*((\s)+Regexp.new(robot.config.robot.name))*[!1?]*$/i, :say_hello)
6
6
  route(/^welcome (.+)/i, :welcome)
7
7
 
8
8
  def say_hello(response)
9
9
  return if response.user.name.empty?
10
- reply_to_name = response.user.metadata['mention_name'].nil? ?
11
- "#{response.user.name}" :
12
- "#{response.user.metadata['mention_name']}"
13
- response.reply "Hello #{reply_to_name}!"
10
+ bot_response = response.message.body.gsub(/[1?!]+/, "").gsub(/(\s)*#{robot.config.robot.name}(\s)*/i, "")
11
+ response.reply "#{bot_response} #{(response.user.mention_name || response.user.name)}"
14
12
  end
15
13
 
16
14
  def welcome(response)
17
15
  response.reply "Hello and Welcome #{response.matches[0][0]}!"
18
16
  end
19
17
 
20
-
21
18
  end
22
19
 
23
20
  Lita.register_handler(Greet)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-greet"
3
- spec.version = "0.1.1"
3
+ spec.version = "0.2.0"
4
4
  spec.authors = ["epinault"]
5
5
  spec.email = ["emmanuel.pinault@zumobi.com"]
6
6
  spec.description = "Make your bot more welcoming and greeting"
@@ -1,19 +1,39 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Lita::Handlers::Greet, lita_handler: true do
4
- it { is_expected.to route("hello dog").to(:say_hello) }
5
- it { is_expected.to route("hi dog").to(:say_hello) }
4
+ it { is_expected.to route("hello").to(:say_hello) }
5
+ it { is_expected.to route("hi there").to(:say_hello) }
6
6
  it { is_expected.to route("yo!").to(:say_hello) }
7
- it { is_expected.to route("good morning").to(:say_hello) }
7
+ it { is_expected.to route("heeeyyyy").to(:say_hello) }
8
+ it { is_expected.to route("greetings").to(:say_hello) }
9
+ it { is_expected.to route("gooooooooood morning").to(:say_hello) }
10
+ it { is_expected.to route("good afternoon").to(:say_hello) }
11
+ it { is_expected.to route("Good evening").to(:say_hello) }
12
+ it { is_expected.to route("good night!").to(:say_hello) }
13
+ it { is_expected.to route("Good Nite").to(:say_hello) }
8
14
  it { is_expected.to route("howdy").to(:say_hello) }
15
+ it { is_expected.to route("sup!").to(:say_hello) }
16
+ it { is_expected.to route("ahoy there").to(:say_hello) }
9
17
 
10
18
  it { is_expected.to route("welcome John Doe").to(:welcome) }
11
19
 
12
- it "sends hello back the user who said hello" do
13
- send_message("Hi")
20
+ it "sends hello back to the user who said hello" do
21
+ send_message("Hello")
14
22
  expect(replies.last).to match(/Hello/)
15
23
  end
16
24
 
25
+ it "sends good morning back to the user name (since no mention_name is supplied) who greeted it" do
26
+ user = Lita::User.create("1", name: "Stephen")
27
+ send_message("Good morning!", as: user)
28
+ expect(replies.last).to match(/Good morning Stephen/)
29
+ end
30
+
31
+ it "sends howdy back to the mention_name of the user who greeted it" do
32
+ user = Lita::User.create("2", name: "Robert", mention_name: "Bob")
33
+ send_message("Howdy", as: user)
34
+ expect(replies.last).to match(/Howdy Bob/)
35
+ end
36
+
17
37
  it "does not send a message when the user object is empty" do
18
38
  user = Lita::User.create("1", name: "")
19
39
  send_message("Hi", as: user)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-greet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - epinault
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-14 00:00:00.000000000 Z
11
+ date: 2016-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  requirements: []
166
166
  rubyforge_project:
167
- rubygems_version: 2.4.8
167
+ rubygems_version: 2.5.1
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: Greeting lita plugin