Class: Spunk::Processor::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/spunk/base_parser.rb

Instance Method Summary collapse

Instance Method Details

#call(hash) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/spunk/base_parser.rb', line 4

def call(hash)
  bot = hash[:bot]
  command = hash[:command]
  parameters = hash[:parameters]
  origin = hash[:origin]
  
  if command =~ /^INVITE #{bot.nickname}$/i
    room = Helpers.parse_room(hash[:parameters])
    hash[:logger].debug "Recieved invite for room #{room}"
    if bot.invite_ok == true
      if room
        bot.join_room(room)
        hash[:logger].debug "Joined #{room}"
      end
    else
      hash[:logger].error "Invite support is turned off... can't be invited to a room"
    end
  end
  if command =~ /^KICK (#\S+)\W(.*)\W?/
    # Remove from array of joined_rooms when kicked
    nick = $2
    if bot.nickname == nick
      room = [$1]
      bot.joined_rooms -= room
    end
  end
end