Skip to content

Commit

Permalink
Disconnect from channels when going away, reconnect when back.
Browse files Browse the repository at this point in the history
  • Loading branch information
Russell Harmon committed May 23, 2013
1 parent a24ea28 commit 31d2c89
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/camper_van/ircd.rb
Expand Up @@ -45,6 +45,8 @@ def initialize(client)
@client = client
@active = true
@channels = {}
@away = false
@saved_channels = nil
end

# The campfire client
Expand Down Expand Up @@ -243,6 +245,20 @@ def shutdown
end

handle :away do |args|
if @away
user_reply 305, "You are no longer marked as being away"
@saved_channels.each do |channel|
join_channel channel
end
@saved_channels = nil
else
user_reply 306, "You have been marked as being away"
@saved_channels = channels.keys
channels.values.each do |channel|
channel.part
end
end
@away = !@away
# ignore silently, there's no campfire API for this
end

Expand Down

0 comments on commit 31d2c89

Please sign in to comment.