Class: QbertBot::Message
- Inherits:
-
Object
- Object
- QbertBot::Message
- Defined in:
- lib/qbert_bot/message.rb
Instance Attribute Summary collapse
-
#channel_id ⇒ Object
Returns the value of attribute channel_id.
-
#channel_name ⇒ Object
Returns the value of attribute channel_name.
-
#matches ⇒ Object
Returns the value of attribute matches.
-
#raw_text ⇒ Object
Returns the value of attribute raw_text.
-
#team_id ⇒ Object
Returns the value of attribute team_id.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#token ⇒ Object
Returns the value of attribute token.
-
#trigger_word ⇒ Object
Returns the value of attribute trigger_word.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
-
#user_name ⇒ Object
Returns the value of attribute user_name.
Instance Method Summary collapse
-
#initialize(bot, post_data) ⇒ Message
constructor
A new instance of Message.
- #reply(text, opts = {}) ⇒ Object
- #say(*args) ⇒ Object
- #text ⇒ Object
Constructor Details
#initialize(bot, post_data) ⇒ 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_id ⇒ Object
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_name ⇒ Object
Returns the value of attribute channel_name.
3 4 5 |
# File 'lib/qbert_bot/message.rb', line 3 def channel_name @channel_name end |
#matches ⇒ Object
Returns the value of attribute matches.
5 6 7 |
# File 'lib/qbert_bot/message.rb', line 5 def matches @matches end |
#raw_text ⇒ Object
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_id ⇒ Object
Returns the value of attribute team_id.
3 4 5 |
# File 'lib/qbert_bot/message.rb', line 3 def team_id @team_id end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/qbert_bot/message.rb', line 3 def end |
#token ⇒ Object
Returns the value of attribute token.
3 4 5 |
# File 'lib/qbert_bot/message.rb', line 3 def token @token end |
#trigger_word ⇒ Object
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_id ⇒ Object
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_name ⇒ Object
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 |
#text ⇒ Object
24 25 26 |
# File 'lib/qbert_bot/message.rb', line 24 def text raw_text.sub(trigger_word, '').strip end |