Class: Slacktail::Message

Inherits:
Base
  • Object
show all
Includes:
HasText, MessageView
Defined in:
lib/slacktail/message.rb

Instance Attribute Summary

Attributes inherited from Base

#data

Attributes included from HasClient

#client

Instance Method Summary collapse

Methods included from MessageView

#render

Methods included from HasText

#text, #text!, #text_lines

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Slacktail::Base

Instance Method Details

#attachmentsObject



41
42
43
# File 'lib/slacktail/message.rb', line 41

def attachments
  @attachments ||= attachments!
end

#channelObject



5
6
7
# File 'lib/slacktail/message.rb', line 5

def channel
  @channel ||= channel!
end

#colorObject



13
14
15
16
17
18
19
# File 'lib/slacktail/message.rb', line 13

def color
  if attachments.any?
    attachments.first.color.to_colsole_color
  else
    :n
  end
end

#empty?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/slacktail/message.rb', line 25

def empty?
  items.empty?
end

#itemsObject



21
22
23
# File 'lib/slacktail/message.rb', line 21

def items
  @items ||= items!
end

#pure_channelObject



9
10
11
# File 'lib/slacktail/message.rb', line 9

def pure_channel
  channel.gsub '#', ''
end

#userObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/slacktail/message.rb', line 29

def user
  result = if data.username
    data.username
  elsif data.user
    client.users[data.user]&.name
  elsif data.bot_id
    client.bots[data.bot_id]&.name
  end

  result || "anonymous"
end