Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed improper parsing of topic reply strings.

  • Loading branch information...
commit 6b7edec65f748a181ac0802cd1df41c4045b6f30 1 parent 27e13da
@david authored
Showing with 8 additions and 8 deletions.
  1. +3 −3 lib/minibot/commands.rb
  2. +5 −5 spec/commands_spec.rb
View
6 lib/minibot/commands.rb
@@ -12,13 +12,13 @@ def topic(channel)
topic = author = timestamp = nil
server.write "TOPIC #{channel}", *EXPECTED_REPLIES_TOPIC do |code, reply|
if code == RPL_TOPIC
- topic = reply
+ channel, topic = reply.split /\s+/, 2
elsif code == RPL_TOPIC_META
- author, timestamp = *reply.split
+ channel, author, timestamp = *reply.split
end
end
- [ topic, author, timestamp && Time.at(timestamp.to_i) ]
+ [ topic && topic[1 .. -1], author, timestamp && Time.at(timestamp.to_i) ]
end
def say(target, message)
View
10 spec/commands_spec.rb
@@ -31,8 +31,8 @@ def initialize(server = nil)
bot = CommandBot.new(mock "server")
bot.server.should_receive(:write).
with("TOPIC #datamapper", *MiniBot::Commands::EXPECTED_REPLIES_TOPIC).
- and_yield("332", "Documentation! http://datamapper.rubyforge.org/").
- and_yield("333", "ssmoot 1212697142")
+ and_yield("332", "#datamapper :Documentation! http://datamapper.rubyforge.org/").
+ and_yield("333", "#datamapper ssmoot 1212697142")
Time.should_receive(:at).with(1212697142).and_return("whoa")
topic, author, time = bot.topic "#datamapper"
@@ -45,7 +45,7 @@ def initialize(server = nil)
bot = CommandBot.new(mock "server")
bot.server.should_receive(:write).
with("TOPIC #datamapper", *MiniBot::Commands::EXPECTED_REPLIES_TOPIC).
- and_yield("331", "There isn't a topic.")
+ and_yield("331", "#datamapper :There isn't a topic.")
topic, author, time = bot.topic "#datamapper"
topic.should be_nil
@@ -57,8 +57,8 @@ def initialize(server = nil)
bot = CommandBot.new(mock "server")
bot.server.should_receive(:write).
with("TOPIC #datamapper", *MiniBot::Commands::EXPECTED_REPLIES_TOPIC).
- and_yield("332", "TOPIC!").
- and_yield("400", "Mary had a little lamb")
+ and_yield("332", "#channel :TOPIC!").
+ and_yield("400", "#channel :Mary had a little lamb")
topic, author, time = bot.topic "#datamapper"
topic.should == "TOPIC!"
Please sign in to comment.
Something went wrong with that request. Please try again.