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
-
#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.
- #post_message(text, options = {}) ⇒ Object
- #say(text, options = {}) ⇒ Object
- #upload(options = {}) ⇒ Object
Constructor Details
#initialize(caller, msg) ⇒ Message
convert message from a Hash obj to a Message obj
7 8 9 10 11 12 |
# File 'lib/slackbotsy/message.rb', line 7 def initialize(caller, msg) super() self.update(msg) @caller = caller # bot object @bot = caller # alias for bot object end |
Instance Method Details
#attach(attachments, options = {}) ⇒ Object
24 25 26 |
# File 'lib/slackbotsy/message.rb', line 24 def attach(, = {}) @caller.attach(, { channel: self['channel_name'] }.merge()) end |
#method ⇒ Object
convenience getter methods for message properties
37 38 39 40 41 |
# File 'lib/slackbotsy/message.rb', line 37 %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
16 17 18 |
# File 'lib/slackbotsy/message.rb', line 16 def post() @caller.post({ channel: self['channel_name'] }.merge()) end |
#post_message(text, options = {}) ⇒ Object
28 29 30 |
# File 'lib/slackbotsy/message.rb', line 28 def (text, = {}) @caller.(text, { channel: self['channel_name'] }.merge()) end |
#say(text, options = {}) ⇒ Object
20 21 22 |
# File 'lib/slackbotsy/message.rb', line 20 def say(text, = {}) @caller.say(text, { channel: self['channel_name'] }.merge()) end |
#upload(options = {}) ⇒ Object
32 33 34 |
# File 'lib/slackbotsy/message.rb', line 32 def upload( = {}) @caller.upload({ channel: self['channel_name'] }.merge()) end |