Class: Rebot::Message

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, bot) ⇒ Message

Returns a new instance of Message.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rebot/message.rb', line 5

def initialize(data, bot)
  @bot     = bot
  @data    = data

  # FIXME: calling private method
  @mention_regex = /\A(<@#{@bot.send(:user_id)}>)[\s\:](.*)/

  @event   = resolve_event(data['type'])
  @text    = cleanup_text(data['text'])
  @user    = data['user']
  @channel = data['channel']
end

Instance Attribute Details

#channelObject (readonly)

Returns the value of attribute channel.



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

def channel
  @channel
end

#eventObject (readonly)

Returns the value of attribute event.



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

def event
  @event
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

#userObject (readonly)

Returns the value of attribute user.



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

def user
  @user
end

Instance Method Details

#[](key) ⇒ Object



22
23
24
# File 'lib/rebot/message.rb', line 22

def [](key)
  @data[key.to_s]
end

#[]=(key, value) ⇒ Object



18
19
20
# File 'lib/rebot/message.rb', line 18

def []=(key, value)
  @data[key.to_s] = value
end