Sha256: 4d6270b7a60c627ab9e5de019658c27fb4ad995934dacabd5579c7491428df07

Contents?: true

Size: 942 Bytes

Versions: 2

Compression:

Stored size: 942 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative '../lib/slack-ruby-block-kit'
require_relative './config'
require_relative './example_helper'
require 'json'

a_prebuilt_block = Slack::BlockKit::Layout::RichText.new
bold_rich_text_section = Slack::BlockKit::Layout::RichText::RichTextSection.new.text(text: 'Bold text', styles: ['bold'])
a_prebuilt_block.append(bold_rich_text_section)

italic_rich_text_section = Slack::BlockKit::Layout::RichText::RichTextSection.new.text(text: 'Italic text', styles: ['italic'])
a_prebuilt_block.append(italic_rich_text_section)

channel_rich_text = Slack::BlockKit::Layout::RichText::RichTextSection.new.channel(channel_id: Config.channel_id, styles: %w[bold italic])
a_prebuilt_block.append(channel_rich_text)

blocks = Slack::BlockKit.blocks do |b|
  b.append(a_prebuilt_block)
end

body = { blocks: blocks.as_json }
puts JSON.pretty_generate(body)

ExampleHelper.post_to_slack(body)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slack-ruby-block-kit-0.25.0 examples/simple_rich_text_blocks.rb
slack-ruby-block-kit-0.24.0 examples/simple_rich_text_blocks.rb