Module: Hector::Commands::Invite

Included in:
Session
Defined in:
lib/hector/commands/invite.rb

Instance Method Summary collapse

Instance Method Details

#on_inviteObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/hector/commands/invite.rb', line 4

def on_invite
  touch_presence
  nickname = request.args.first
  if session = Session.find(nickname)
    channel = Channel.find(request.args[1])
    if channels.include?(channel)
      if !session.channels.include?(channel)
        session.deliver(:invite, self, :source => source, :text => request.text)
      else
        respond_with("443", nickname, channel.name, "is already on channel", :source => Hector.server_name)
      end
    else
      respond_with("442", request.args[1], "You're not on that channel", :source => Hector.server_name)
    end
  else
    raise NoSuchNickOrChannel, nickname
  end        
end