GithubHelp home page GithubHelp logo

codelittinc / slacked Goto Github PK

View Code? Open in Web Editor NEW
144.0 6.0 10.0 28 KB

A simple and easy way to send notifications to Slack from your Ruby or Rails application.

License: MIT License

Ruby 98.51% Shell 1.49%

slacked's Introduction

Gem Version Circle CI

Slacked

This is a super simple Slack integration for Ruby and for Ruby and Rails applications. A use case for this would be to post a notification in Slack when a new User is created or a certain action has been taken in your application.

Are there other gems that provide similar functionality? Yes. Do some of them provide more flexibility? Yes. The point of this was to make installing and integrating a 30 second process.

This gem can be used with a rails application and enabled/disabled based on the environment config as you may see below

Getting Started

without rails

gem install slacked

With rails

Add this line to your application's Gemfile:

gem 'slacked'

And then execute:

$ bundle

Then run the installer:

$ bundle exec rails g slacked:install

This will create a .env file in the root of the rails application. Specify the default Webhook Url and the message to be sent.

SLACK_WEBHOOK= "WEBHOOK_URL"
SLACK_DEFAULT_MESSAGE= "TEST"

Usage

Set the SLACK_WEBHOOK env variable with the default value of the webhook which you want to send the messages. If you would like to send messages to different webhooks, you can do so by specifying the webhook url in the config parameter to Slacked#post or Slacked#post_async. If you want to send a unique message in your application like 'Application is running' you can set the SLACK_DEFAULT_MESSAGE and call the message methods without sending an argument.

To send a sync message to slack use the method:

Slacked.post "This is a test post"

or

Slacked.post

The last example will use the SLACK_DEFAULT_MESSAGE value

To send an async message to slack use the method:

Slacked.post_async "This is a test post"

or

Slacked.post_async

The last example will use the SLACK_DEFAULT_MESSAGE value

To pass the config:

Slacked.post "I have a message from the underworld!", {icon_emoji: ':ghost:'}

or

Slacked.post_async "Let's play fetch!", {icon_emoji: ':dog:'}

or

Slacked.post_async 'This goes to a specific channel!', {webhook_url: <WEBHOOK_URL>}

Right now we only have the config for the icon and the webhook url, if you need another one let us know or submit a pull request.

Example

class Post < ActiveRecord::Base
  after_create :slacked

  private

  def slacked
    Slacked.post 'post created!'
  end
end

Using with rails

If you are using this gem inside a rails application you can enable or disable it based on your environment, to do it you only need to add the code below in your config file.

config.slacked_disabled = true

The default value is false

Contributors

License

The gem is available as open source under the terms of the MIT License.

slacked's People

Contributors

codelitt avatar icortex avatar kaiomagalhaes avatar seathony avatar thalessr avatar tomasbarry avatar weilandia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

slacked's Issues

How do I set an emoji?

First of all thank you! It was amazing to get slack integrated so quickly.

I have tried setting an image/emoji in the actual slack api web interface for this particular web hook, but this doesn't seem to matter, I am still served the standard 'bot' icon inside of the app.

It would be nice if I could choose the icon for my posts to slack, especially if I could associate different icons for different actions etc. Is this possible through your gem? Sorry if I am missing something obvious here. Thanks!

Introduce Rubocop

When contributing to the Slacked project, there are no checks on code styles etc. I propose introducing Rubocop, and potentially HoundCI so that there are consistent coding guidelines and checks to ensure that this project maintains well written Ruby code.

I have experience with both Rubocop and Hound and have introduced both in a number of projects and would be willing to do so with Slacked if the maintainers see this as a valuable addition?

Update README

  1. Needs some clarification about the default message
  2. Needs an update on the summary/description. Should make it clear that this is just meant to be a dead simple way to implement things. Maybe something like what we can do for the gemspec. #7

Update gemspec

Authors, summary and description.

For summary maybe:

A super simple and easy way to send notifications to Slack from your Rails application.

Description?? I'm not sure. Maybe:

This is a super simple Slack integration for Rails. A use case for this would be to post a notification in Slack when a new User is created or a certain action has been taken in your application.

Are there other gems that provide similar functionality? Yes. Do some of them provide more flexibility? Yes. The point of this was to make installing and integrating a 30 second process.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.