Class: Nico::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/nico/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Message

Returns a new instance of Message.



8
9
10
11
# File 'lib/nico/message.rb', line 8

def initialize(json)
  # also available: id, user_id, starred, created_at, type, room_id
  @body = json['body'] || ''
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/nico/message.rb', line 6

def body
  @body
end

Instance Method Details

#relevant?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/nico/message.rb', line 13

def relevant?
  @body.start_with? *Nico::ALIASES
end

#responseObject



17
18
19
20
21
22
23
24
# File 'lib/nico/message.rb', line 17

def response
  # This should loop through the regex and respond adequately
  # And one of these regex will add to the regex (and save to github)
  case @body
    when Matchers::DaftPunkMatcher.match then Matchers::DaftPunkMatcher.response
    else "You said #{@body}"
  end
end