Code Monkey home page Code Monkey logo

clj-slackbot's Introduction

Deploy

clj-slackbot

A clojure project to run a eval bot which can be easily hooked up in Slack.

How to run?

Please note that configuration stuff has now changed. Also, things are relatively newer and untested. This will soon be fixed. Right now is probably not a good time to upgrade to the newer stuff.

You need to create a config.edn file based on the config.example.edn file available in the repository. This file needs to be in the current path. The program just looks for config.edn in the current directory.

This bot now supports different kinds of comm-links (communication channels to talk to slack). You can either use the older webhook configuration, or you can use the newer RTM API from Slack to setup a bot.

Using the Webhook configuration

Webhook configuration needs four things defined in config.edn:

  • :comm :clj-slackbot.comms.slack-web-hook/start
  • :post-url - The post URL to post responses to a channel.
  • :command-token - The token you get when you create a slash command in slack. Usually something like /clj.
  • :port - The port to run the web-server on.

Webhook works by listening to slash command requests and then responding to them using a channel post.

Once you have the program running with this comm-link, it will start a web server on the specified port and listen for requests on /clj end-point. It is made to accept slack command (with clojure to evaluate in the "text" field). The evaluated result is sent out to the POST url on the same channel on which it was received.

Please see the section on Incoming Webhooks and Slash Commands.

Using the RTM API Bot

WARNING: New Stuff

You can create a bot in slack which should give you an api-token. Please see this for more details. You need the following configuration to setup an RTM API:

  • :comm :clj-slackbot.comms.slack-rtm/start
  • :api-token - The bot token you'll get once you create a slack bot.
  • :prefix - The prefix which triggers eval. E.g. you could set it to a , and then messages to the channel like ,(+ 1 1) will be evaluated by the bot.

Please see the section on Bot Users.

Running the bot

Copy the .java.policy file to your home directory.

If you have the jar file, just do:

java -jar clj-slackbot.jar

Or can checkout the source and run:

lein run

If your configuration file is not in the current directory of the program, you can specify a CONFIG_FILE environment variable pointing to the location of the configuration file.

CONFIG_FILE=/path/to/config.edn java -jar clj-slackbot.jar

License

Copyright © 2014 Uday Verma. Licensed under the same terms as Clojure (EPL).

clj-slackbot's People

Contributors

kthelgason avatar lsenjov avatar m1dnight avatar osbert avatar trmanderson avatar verma avatar

Watchers

 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.