Class: Slackbotsy::Message
- Inherits:
-
Hash
- Object
- Hash
- Slackbotsy::Message
- Includes:
- Helper
- Defined in:
- lib/slackbotsy/message.rb
Instance Method Summary collapse
-
#initialize(caller, msg) ⇒ Message
constructor
convert message from a Hash obj to a Message obj.
-
#method ⇒ Object
convenience getter methods for message properties.
-
#say(text, options = {}) ⇒ Object
call say without bot object.
Constructor Details
#initialize(caller, msg) ⇒ Message
convert message from a Hash obj to a Message obj
7 8 9 10 11 |
# File 'lib/slackbotsy/message.rb', line 7 def initialize(caller, msg) super() self.update(msg) @caller = caller # bot object end |
Instance Method Details
#method ⇒ Object
convenience getter methods for message properties
20 21 22 23 24 |
# File 'lib/slackbotsy/message.rb', line 20 %w[ token team_id channel_id channel_name timestamp user_id user_name text ].each do |method| define_method(method) do self.fetch(method, nil) end end |
#say(text, options = {}) ⇒ Object
call say without bot object
14 15 16 17 |
# File 'lib/slackbotsy/message.rb', line 14 def say(text, = {}) [:channel] ||= self['channel_name'] # default to same channel as msg @caller.say(text, ) end |