Class: Slack::WebsocketIncomingMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/edi/slack/websocket_incoming_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#channelObject

Returns the value of attribute channel.



3
4
5
# File 'lib/edi/slack/websocket_incoming_message.rb', line 3

def channel
  @channel
end

#textObject

Returns the value of attribute text.



3
4
5
# File 'lib/edi/slack/websocket_incoming_message.rb', line 3

def text
  @text
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/edi/slack/websocket_incoming_message.rb', line 3

def type
  @type
end

#userObject

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

Returns:

  • (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

Returns:

  • (Boolean)


20
21
22
# File 'lib/edi/slack/websocket_incoming_message.rb', line 20

def message_type?
  type == "message"
end

#should_respond?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/edi/slack/websocket_incoming_message.rb', line 16

def should_respond?
  message_type? && mentions_edi?
end

#to_sObject



12
13
14
# File 'lib/edi/slack/websocket_incoming_message.rb', line 12

def to_s
  "Slack::WebsocketMessage text: #{self.text}"
end