lita-slack 1.0.4 → 1.0.5

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: 94fa7740895d09a183b18621b296e01c0b9bf4ba
4
- data.tar.gz: 8d092bb60ea02b23c43f53551e6ca691d5654d00
3
+ metadata.gz: f17abc31f51924e4c36f96a2e4bfbdbb4ffd2d4f
4
+ data.tar.gz: 1df989c692141fcc9e052ffcd701fbefda6dcfb0
5
5
  SHA512:
6
- metadata.gz: 9478684ba8c9c77579c3224559cff79b49a7fcf2f30c361997d2e1d53ee777269e6da9bcd0b542fac591a1b7ed20ce27a708ad25db19675bd7ca51367c83cb2b
7
- data.tar.gz: 1746b869ac92e8a99d3cc8bcad47ea21707625b28dbc6607d6b8684d023e118eb8ec6cc06ed89082607ebf428a18de6bc3055da3eb32c1a59d062560d9650a42
6
+ metadata.gz: 5018da29c4758866976afc93ea3f649a27877b54ae1eb531e8f4af941b13e68e0f6793f3c157d6ff4b7885eddade956df031783d487c12604e8b76b08e00a2d2
7
+ data.tar.gz: 5c44dace1fa28b9af419a67d1718d104173d3ba7a3f397cf060467b5cbd1a174dbbd96d9e2c6da1b7881ebb69ed597fae3e331c723b5135ff1f96261ea70effd
@@ -43,7 +43,9 @@ module Lita
43
43
 
44
44
  def dispatch_message(user)
45
45
  source = Source.new(user: user, room: channel)
46
+ source.private_message! if channel && channel[0] == "D"
46
47
  message = Message.new(robot, body, source)
48
+ message.command! if source.private_message?
47
49
  log.debug("Dispatching message to Lita from #{user.id}.")
48
50
  robot.receive(message)
49
51
  end
@@ -21,7 +21,7 @@ module Lita
21
21
 
22
22
  def initialize(robot, token, team_data)
23
23
  @robot = robot
24
- @im_mapping = IMMapping.new(token, team_data.ims)
24
+ @im_mapping = IMMapping.new(API.new(token), team_data.ims)
25
25
  @websocket_url = team_data.websocket_url
26
26
  @robot_id = team_data.self.id
27
27
 
data/lita-slack.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-slack"
3
- spec.version = "1.0.4"
3
+ spec.version = "1.0.5"
4
4
  spec.authors = ["Ken J.", "Jimmy Cuadra"]
5
5
  spec.email = ["kenjij@gmail.com", "jimmy@jimmycuadra.com"]
6
6
  spec.description = %q{Lita adapter for Slack.}
@@ -26,8 +26,8 @@ describe Lita::Adapters::Slack::MessageHandler, lita: true do
26
26
  "text" => "Hello"
27
27
  }
28
28
  end
29
- let(:message) { instance_double('Lita::Message') }
30
- let(:source) { instance_double('Lita::Source') }
29
+ let(:message) { instance_double('Lita::Message', command!: false) }
30
+ let(:source) { instance_double('Lita::Source', private_message?: false) }
31
31
  let(:user) { instance_double('Lita::User', id: 'U023BECGF') }
32
32
 
33
33
  before do
@@ -46,6 +46,38 @@ describe Lita::Adapters::Slack::MessageHandler, lita: true do
46
46
  subject.handle
47
47
  end
48
48
 
49
+ context "when the message is a direct message" do
50
+ let(:data) do
51
+ {
52
+ "type" => "message",
53
+ "channel" => "D2147483705",
54
+ "user" => "U023BECGF",
55
+ "text" => "Hello"
56
+ }
57
+ end
58
+
59
+ before do
60
+ allow(Lita::Source).to receive(:new).with(
61
+ user: user,
62
+ room: "D2147483705"
63
+ ).and_return(source)
64
+ allow(source).to receive(:private_message!).and_return(true)
65
+ allow(source).to receive(:private_message?).and_return(true)
66
+ end
67
+
68
+ it "marks the source as a private message" do
69
+ expect(source).to receive(:private_message!)
70
+
71
+ subject.handle
72
+ end
73
+
74
+ it "marks the message as a command" do
75
+ expect(message).to receive(:command!)
76
+
77
+ subject.handle
78
+ end
79
+ end
80
+
49
81
  context "when the message starts with a Slack-style @-mention" do
50
82
  let(:data) do
51
83
  {
@@ -44,7 +44,10 @@ describe Lita::Adapters::Slack::RTMConnection, lita: true do
44
44
 
45
45
  describe "#im_for" do
46
46
  before do
47
- allow(Lita::Adapters::Slack::IMMapping).to receive(:new).and_return(im_mapping)
47
+ allow(Lita::Adapters::Slack::API).to receive(:new).with(token).and_return(api)
48
+ allow(
49
+ Lita::Adapters::Slack::IMMapping
50
+ ).to receive(:new).with(api, []).and_return(im_mapping)
48
51
  allow(im_mapping).to receive(:im_for).with('U12345678').and_return('D024BFF1M')
49
52
  end
50
53
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-slack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken J.