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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f17abc31f51924e4c36f96a2e4bfbdbb4ffd2d4f
|
4
|
+
data.tar.gz: 1df989c692141fcc9e052ffcd701fbefda6dcfb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
@@ -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::
|
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
|
|