Class: Slackbotsy::Message
- Inherits:
-
Hash
- Object
- Hash
- Slackbotsy::Message
- Includes:
- Helper
- Defined in:
- lib/slackbotsy/message.rb
Instance Method Summary collapse
-
#attach(attachments, options = {}) ⇒ Object
ditto.
-
#initialize(caller, msg) ⇒ Message
constructor
convert message from a Hash obj to a Message obj.
-
#method ⇒ Object
convenience getter methods for message properties.
-
#post(options) ⇒ Object
convenience wrapper in message scope, so we can call it without @caller and set default channel to same as received message.
-
#say(text, options = {}) ⇒ Object
ditto.
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
#attach(attachments, options = {}) ⇒ Object
ditto
25 26 27 |
# File 'lib/slackbotsy/message.rb', line 25 def attach(, = {}) @caller.attach(, { channel: self['channel_name'] }.merge()) end |
#method ⇒ Object
convenience getter methods for message properties
30 31 32 33 34 |
# File 'lib/slackbotsy/message.rb', line 30 %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 |
#post(options) ⇒ Object
convenience wrapper in message scope, so we can call it without @caller and set default channel to same as received message
15 16 17 |
# File 'lib/slackbotsy/message.rb', line 15 def post() @caller.post({ channel: self['channel_name'] }.merge()) end |
#say(text, options = {}) ⇒ Object
ditto
20 21 22 |
# File 'lib/slackbotsy/message.rb', line 20 def say(text, = {}) @caller.say(text, { channel: self['channel_name'] }.merge()) end |