Class: QbertBot::Message

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bot, post_data) ⇒ Message

Returns a new instance of Message.



7
8
9
10
11
12
13
14
# File 'lib/qbert_bot/message.rb', line 7

def initialize(bot, post_data)
  @bot = bot
  [:token, :team_id, :channel_id, :channel_name, :timestamp,
   :user_id, :user_name, :trigger_word].each do |k|
    send("#{k.to_s}=", post_data[k])
  end
  self.raw_text = post_data[:text]
end

Instance Attribute Details

#channel_idObject

Returns the value of attribute channel_id.



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

def channel_id
  @channel_id
end

#channel_nameObject

Returns the value of attribute channel_name.



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

def channel_name
  @channel_name
end

#matchesObject

Returns the value of attribute matches.



5
6
7
# File 'lib/qbert_bot/message.rb', line 5

def matches
  @matches
end

#raw_textObject

Returns the value of attribute raw_text.



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

def raw_text
  @raw_text
end

#team_idObject

Returns the value of attribute team_id.



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

def team_id
  @team_id
end

#timestampObject

Returns the value of attribute timestamp.



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

def timestamp
  @timestamp
end

#tokenObject

Returns the value of attribute token.



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

def token
  @token
end

#trigger_wordObject

Returns the value of attribute trigger_word.



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

def trigger_word
  @trigger_word
end

#user_idObject

Returns the value of attribute user_id.



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

def user_id
  @user_id
end

#user_nameObject

Returns the value of attribute user_name.



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

def user_name
  @user_name
end

Instance Method Details

#reply(text, opts = {}) ⇒ Object



20
21
22
# File 'lib/qbert_bot/message.rb', line 20

def reply(text, opts = {})
  say(channel_name, text, opts)
end

#say(*args) ⇒ Object



16
17
18
# File 'lib/qbert_bot/message.rb', line 16

def say(*args)
  @bot.say(*args)
end

#textObject



24
25
26
# File 'lib/qbert_bot/message.rb', line 24

def text
  raw_text.sub(trigger_word, '').strip
end