Gem Version Master

SlackNotifier

Simple Ruby gem for sending messages to Slack

slack notifier

Installation

Add this line to your application's Gemfile:

gem 'slack_notifier'

And then execute:

$ bundle

Or install it yourself as:

$ gem install slack_notifier

Configuration

SlackNotifier.configure({
  default_channel: 'deployment-alerts',
  default_nickname: 'Deployment Bot',
  default_icon_emoji: ':ship:',
  default_report_title: 'Details',
  default_report_color: '#D3D3D3',
  webhook_url: 'https://hooks.slack.com/services/X01XXYY11/A1XXY1X00/YYYYYYYYYYYYYYYYYY',
  raise_delivery_errors: false
})

Usage

Send directly

SlackNotifier::Message.send(
  text: "This uses all default configuration",
  report: 'Some report/attachment text'
)

# Customizing default configuration
SlackNotifier::Message.send(
  channel: 'errors',
  nickname: 'Bugs',
  text: ex.message,
  icon_emoji: ':bug:',
  report: ex.backtrace,
  report_color: '#D3D3D3',
  report_title: 'Backtrace'
)

Send later

message = SlackNotifier::Message.compose(
  text: "This uses all default configuration",
  report: 'Some report/attachment text'
)

message.deliver

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/FindHotel/ruby_slack_notifier.