Class: Slkecho::BlocksBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/slkecho/blocks_builder.rb

Instance Method Summary collapse

Instance Method Details

#build_from_json(json, user_id = nil) ⇒ Object



19
20
21
# File 'lib/slkecho/blocks_builder.rb', line 19

def build_from_json(json, user_id = nil)
  JSON.parse(json.gsub("<mention>", "<@#{user_id}>"))
end

#build_from_message(message, user_id = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/slkecho/blocks_builder.rb', line 7

def build_from_message(message, user_id = nil)
  [
    {
      type: "section",
      text: {
        type: "mrkdwn",
        text: user_id.nil? ? message : "<@#{user_id}> #{message}"
      }
    }
  ]
end