Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 03c2208

Browse files
committed
Use Source#private_message? to determine message targets.
1 parent aa33822 commit 03c2208

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/lita/adapters/irc.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ def run
2626
end
2727

2828
def send_messages(target, strings)
29-
if target.room
30-
channel = Cinch::Channel.new(target.room, cinch)
31-
strings.each { |s| channel.msg(s) }
32-
else
29+
if target.private_message?
3330
user = Cinch::User.new(target.user.name, cinch)
3431
strings.each { |s| user.msg(s) }
32+
else
33+
channel = Cinch::Channel.new(target.room, cinch)
34+
strings.each { |s| channel.msg(s) }
3535
end
3636
end
3737

spec/lita/adapters/irc_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
describe "#send_messages" do
6161
it "sends messages to rooms" do
62-
source = double("Lita::Source", room: "#foo")
62+
source = double("Lita::Source", room: "#foo", private_message?: false)
6363
channel = double("Cinch::Channel")
6464
allow(Cinch::Channel).to receive(:new).with(
6565
"#foo",
@@ -72,7 +72,7 @@
7272

7373
it "sends messages to users" do
7474
user = double("Lita::User", name: "Carl")
75-
source = double("Lita::Source", room: nil, user: user)
75+
source = double("Lita::Source", user: user, private_message?: true)
7676
user = double("Cinch::User")
7777
allow(Cinch::User).to receive(:new).with(
7878
"Carl",

0 commit comments

Comments
 (0)