Class: Slack::WebsocketIncomingMessage
- Inherits:
-
Object
- Object
- Slack::WebsocketIncomingMessage
- Defined in:
- lib/edi/slack/websocket_incoming_message.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#text ⇒ Object
Returns the value of attribute text.
-
#type ⇒ Object
Returns the value of attribute type.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(params) ⇒ WebsocketIncomingMessage
constructor
A new instance of WebsocketIncomingMessage.
- #mentions_edi? ⇒ Boolean
- #message_type? ⇒ Boolean
- #should_respond? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(params) ⇒ WebsocketIncomingMessage
Returns a new instance of WebsocketIncomingMessage.
4 5 6 7 8 9 10 |
# File 'lib/edi/slack/websocket_incoming_message.rb', line 4 def initialize(params) params = JSON.parse(params) @channel = params["channel"] @user = params["user"] @text = params["text"] @type = params["type"] end |
Instance Attribute Details
#channel ⇒ Object
Returns the value of attribute channel.
3 4 5 |
# File 'lib/edi/slack/websocket_incoming_message.rb', line 3 def channel @channel end |
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/edi/slack/websocket_incoming_message.rb', line 3 def text @text end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/edi/slack/websocket_incoming_message.rb', line 3 def type @type end |
#user ⇒ Object
Returns the value of attribute user.
3 4 5 |
# File 'lib/edi/slack/websocket_incoming_message.rb', line 3 def user @user end |
Instance Method Details
#mentions_edi? ⇒ Boolean
24 25 26 27 28 29 30 |
# File 'lib/edi/slack/websocket_incoming_message.rb', line 24 def mentions_edi? if text !!text.match(/#{EDI.bot_name}(\W|$)/i) else false end end |
#message_type? ⇒ Boolean
20 21 22 |
# File 'lib/edi/slack/websocket_incoming_message.rb', line 20 def type == "message" end |
#should_respond? ⇒ Boolean
16 17 18 |
# File 'lib/edi/slack/websocket_incoming_message.rb', line 16 def should_respond? && mentions_edi? end |
#to_s ⇒ Object
12 13 14 |
# File 'lib/edi/slack/websocket_incoming_message.rb', line 12 def to_s "Slack::WebsocketMessage text: #{self.text}" end |