Module: Ruboty::SlackRtm::ChannelCreated

Defined in:
lib/ruboty/slack_rtm/channel_created.rb,
lib/ruboty/slack_rtm/channel_created/version.rb

Constant Summary collapse

CHANNEL =
ENV["SLACK_CHANNEL_CREATED_NOTIFY_CHANNEL"] || "#new_channel"
VERSION =
"0.1.1"

Instance Method Summary collapse

Instance Method Details

#on_channel_created(data) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ruboty/slack_rtm/channel_created.rb', line 10

def on_channel_created(data)
  channel_id = data["channel"]["id"]
  message = "A new channel created: <##{channel_id}>"
  attachments = [
    {
      fallback: message,
      color: "good",
      text: message
    }
  ]

  channel = CHANNEL
  channel = resolve_channel_id(channel[1..-1]) if channel.start_with?("#")
  client.chat_postMessage(
    channel: channel,
    username: robot.name,
    attachments: attachments.to_json
  )
end