Giter Club home page Giter Club logo

slack-emoji-bot's Introduction

Build Status Code Climate


slack-emoji-bot

Emoji bot

Simple bot that detects new Slack emoji added through https://my.slack.com/customize/emoji and notifies a channel about them. Intended to run on a schedule, such as every hour, using cron.

Emoji-bot uses the slack-ruby-client gem to easily interact with the Slack API. On initial run, the emoji.list method is called and the list of all emoji is saved in an emoji.txt file. Every subsequent time the script is run, it asks Slack for the emoji list again and compares the existing emoji and the new list. If any new emoji are found, the chat.postMessage method is called with a random response from responses.txt and the new emoji. Finally, the new list of emoji are saved in emoji.txt.

Running with Docker

The simplest way to run is with docker, which will check every hour for new emoji in a container:

docker run -it -d \
  -e SLACK_API_TOKEN="$TOKEN" \
  -e SLACK_CHANNEL="#emojis" \
  -e SLACK_USERNAME="emoji-bot" \
  -e SLACK_ICON_EMOJI=":parrot:" \
  --name emoji-bot \
  dpca/slack-emoji-bot

You can see if the container is up by using docker ps, and check its logs with docker logs emoji-bot. Omit the -d option to run the docker container in the foreground for development purposes.

You can request a token for testing purposes from https://api.slack.com/docs/oauth-test-tokens but should use a bot token from https://my.slack.com/services/new/bot for a real deployment. Read more about bot users here: https://api.slack.com/bot-users

If not provided, SLACK_USERNAME defaults to "emoji-bot" and SLACK_ICON_EMOJI defaults to ":parrot:".

Running locally

Setup

First, you need to set your SLACK_API_TOKEN and SLACK_CHANNEL to message in .env. Then, save initial emoji:

bundle install
./emoji-bot.rb --setup

Run

./emoji-bot.rb

Cron

You can run the emoji-bot automatically by adding something like the following to your crontab (crontab -e):

0 * * * * cd /home/USER/slack-emoji-bot && /usr/local/bin/ruby emoji-bot.rb >> /home/USER/slack-emoji-bot/cronOutput.txt 2>&1

slack-emoji-bot's People

Contributors

dpca avatar

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.