Browse files

channel password can be part of an irc uri as follows: 'irc://test-sh…

…out-bot@irc.freenode.net:6667/#channel?password'. This fix updates the join method to split on '?', which splits the channel name from the password. The @channel_password variable then takes the uri channel password first, the shout-bot initialize password second (to maintain backwards compatibility), or the empty string if neither exist.
  • Loading branch information...
1 parent 416e0ef commit 92ec76d01ef74dd28bb043438543b5776576c841 @haus haus committed Feb 29, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/shout-bot.rb
View
8 lib/shout-bot.rb
@@ -62,10 +62,10 @@ def initialize(server, port, nick, password=nil)
def join(channel, password = nil)
raise ArgumentError unless block_given?
-
- @channel = "##{channel}"
- password = password && " #{password}" || ""
- @socket.puts "JOIN #{@channel}#{password}"
+ params = channel.split('?')
+ @channel = "##{params[0]}"
+ @channel_password = params[1] || password || ""
+ @socket.puts "JOIN #{@channel} #{@channel_password}"
yield self
@socket.puts "PART #{@channel}"
end

0 comments on commit 92ec76d

Please sign in to comment.