Class: Hipbot::Message

Inherits:
Struct
  • Object
show all
Includes:
Cache
Defined in:
lib/hipbot/message.rb

Constant Summary collapse

MENTION_REGEXP =
/@(\p{Word}++):?/.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Cache

#_cache

Constructor Details

#initialize(*args) ⇒ Message

Returns a new instance of Message.



10
11
12
13
14
15
# File 'lib/hipbot/message.rb', line 10

def initialize *args
  super
  Hipbot.logger.info("MESSAGE from #{sender} in ##{room}")
  self.raw_body = raw_body.force_encoding('UTF-8')
  self.body     = strip_bot_mention
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



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

def body
  @body
end

#raw_bodyObject

Returns the value of attribute raw_body

Returns:

  • (Object)

    the current value of raw_body



3
4
5
# File 'lib/hipbot/message.rb', line 3

def raw_body
  @raw_body
end

#roomObject

Returns the value of attribute room

Returns:

  • (Object)

    the current value of room



3
4
5
# File 'lib/hipbot/message.rb', line 3

def room
  @room
end

#senderObject

Returns the value of attribute sender

Returns:

  • (Object)

    the current value of sender



3
4
5
# File 'lib/hipbot/message.rb', line 3

def sender
  @sender
end

Instance Method Details

#for?(user) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/hipbot/message.rb', line 17

def for? user
  recipients.include? user.mention
end

#private?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/hipbot/message.rb', line 29

def private?
  room.nil?
end